home *** CD-ROM | disk | FTP | other *** search
Unknown | 1987-12-12 | 19.0 KB |
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was not able to be converted.
This format is not currently supported by dexvert.
Confidence | Program | Detection | Match Type | Support
|
---|
1%
| dexvert
| WANG Integrated Word Processor (document/wangIWP)
| ext
| Unsupported |
1%
| dexvert
| Dynamic Publisher Document (document/dynamicPublisherDocument)
| ext
| Unsupported |
1%
| dexvert
| Excellence! Document (document/excellenceDocument)
| ext
| Unsupported |
1%
| dexvert
| Norton Textra Writer (document/textraWriter)
| ext
| Unsupported |
1%
| dexvert
| IBM DisplayWrite Document (document/ibmDisplayWriteDocument)
| ext
| Unsupported |
100%
| file
| data
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 1b 32 1b 55 00 1b 36 1b | 38 1b 41 0c 1b 32 1b 47 |.2.U..6.|8.A..2.G|
|00000010| 1b 43 42 0d 0a 0d 0a 0d | 0a 0d 0a 20 20 20 20 20 |.CB.....|... |
|00000020| 1b 45 43 48 41 50 54 45 | 52 20 38 1b 46 20 20 20 |.ECHAPTE|R 8.F |
|00000030| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 1b 45 | | .E|
|00000040| 53 4f 52 54 49 4e 47 20 | 49 54 20 41 4c 4c 20 4f |SORTING |IT ALL O|
|00000050| 55 54 20 20 1b 46 20 20 | 20 20 20 20 20 20 20 20 |UT .F | |
|00000060| 20 20 20 20 20 20 20 1b | 45 43 48 41 50 54 45 52 | .|ECHAPTER|
|00000070| 20 38 0d 0a 0d 0a 0d 0a | 20 20 20 20 20 53 4f 52 | 8......| SOR|
|00000080| 54 49 4e 47 0d 0a 0d 0a | 20 20 20 20 20 1b 46 49 |TING....| .FI|
|00000090| 6e 20 74 68 69 73 20 63 | 68 61 70 74 65 72 2c 20 |n this c|hapter, |
|000000a0| 79 6f 75 20 77 69 6c 6c | 20 6c 65 61 72 6e 20 74 |you will| learn t|
|000000b0| 6f 20 73 6f 72 74 20 74 | 68 65 20 63 6f 6e 74 65 |o sort t|he conte|
|000000c0| 6e 74 73 20 6f 66 20 79 | 6f 75 72 20 70 72 6f 67 |nts of y|our prog|
|000000d0| 72 61 6d 0d 0a 20 20 20 | 20 20 74 61 62 6c 65 73 |ram.. | tables|
|000000e0| 2e 20 20 53 6f 72 74 69 | 6e 67 2c 20 74 68 65 20 |. Sorti|ng, the |
|000000f0| 70 72 6f 63 65 73 73 20 | 6f 66 20 73 65 71 75 65 |process |of seque|
|00000100| 6e 63 69 6e 67 20 61 20 | 6c 69 73 74 20 69 6e 20 |ncing a |list in |
|00000110| 65 69 74 68 65 72 20 61 | 73 63 65 6e 64 69 6e 67 |either a|scending|
|00000120| 0d 0a 20 20 20 20 20 6f | 72 20 64 65 73 63 65 6e |.. o|r descen|
|00000130| 64 69 6e 67 20 6f 72 64 | 65 72 2c 20 61 64 64 73 |ding ord|er, adds|
|00000140| 20 61 20 6c 6f 74 20 6f | 66 20 70 6f 77 65 72 20 | a lot o|f power |
|00000150| 74 6f 20 79 6f 75 72 20 | 72 65 70 65 72 74 6f 69 |to your |repertoi|
|00000160| 72 65 2e 20 20 59 6f 75 | 72 0d 0a 20 20 20 20 20 |re. You|r.. |
|00000170| 6c 6f 67 69 63 20 63 61 | 6e 20 74 61 6b 65 20 61 |logic ca|n take a|
|00000180| 64 76 61 6e 74 61 67 65 | 20 6f 66 20 73 6f 72 74 |dvantage| of sort|
|00000190| 65 64 20 73 65 71 75 65 | 6e 63 65 73 20 74 6f 20 |ed seque|nces to |
|000001a0| 74 65 73 74 20 61 6e 64 | 20 70 72 6f 63 65 73 73 |test and| process|
|000001b0| 20 61 6e 64 0d 0a 20 20 | 20 20 20 79 6f 75 72 20 | and.. | your |
|000001c0| 6f 75 74 70 75 74 20 63 | 61 6e 20 62 65 20 6d 61 |output c|an be ma|
|000001d0| 64 65 20 65 61 73 69 65 | 72 20 74 6f 20 72 65 61 |de easie|r to rea|
|000001e0| 64 20 61 6e 64 20 75 6e | 64 65 72 73 74 61 6e 64 |d and un|derstand|
|000001f0| 2e 0d 0a 0d 0a 20 20 20 | 20 20 4c 65 74 27 73 20 |..... | Let's |
|00000200| 73 6f 72 74 20 61 20 6c | 69 73 74 20 6f 66 20 6e |sort a l|ist of n|
|00000210| 61 6d 65 73 20 6d 61 6e | 75 61 6c 6c 79 20 61 6e |ames man|ually an|
|00000220| 64 20 67 65 74 20 61 20 | 66 65 65 6c 20 66 6f 72 |d get a |feel for|
|00000230| 20 68 6f 77 20 74 68 65 | 20 63 72 65 61 74 75 72 | how the| creatur|
|00000240| 65 0d 0a 20 20 20 20 20 | 77 6f 72 6b 73 2e 0d 0a |e.. |works...|
|00000250| 0d 0a 0d 0a 20 20 20 20 | 20 31 20 20 53 6d 69 74 |.... | 1 Smit|
|00000260| 68 0d 0a 20 20 20 20 20 | 32 20 20 4a 6f 6e 65 73 |h.. |2 Jones|
|00000270| 0d 0a 20 20 20 20 20 33 | 20 20 41 6d 65 73 0d 0a |.. 3| Ames..|
|00000280| 20 20 20 20 20 34 20 20 | 48 65 72 6d 61 6e 0d 0a | 4 |Herman..|
|00000290| 0d 0a 0d 0a 20 20 20 20 | 20 53 74 61 72 74 20 62 |.... | Start b|
|000002a0| 79 20 63 6f 6d 70 61 72 | 69 6e 67 20 74 68 65 20 |y compar|ing the |
|000002b0| 31 73 74 20 61 6e 64 20 | 32 6e 64 20 65 6e 74 72 |1st and |2nd entr|
|000002c0| 69 65 73 2e 20 20 49 66 | 20 74 68 65 20 31 73 74 |ies. If| the 1st|
|000002d0| 20 69 73 20 67 72 65 61 | 74 65 72 20 74 68 61 6e | is grea|ter than|
|000002e0| 0d 0a 20 20 20 20 20 74 | 68 65 20 32 6e 64 2c 20 |.. t|he 2nd, |
|000002f0| 73 77 61 70 20 74 68 65 | 6d 2e 20 20 43 6f 6c 75 |swap the|m. Colu|
|00000300| 6d 6e 20 31 20 73 68 6f | 77 73 20 74 68 65 20 6f |mn 1 sho|ws the o|
|00000310| 72 69 67 69 6e 61 6c 20 | 6c 69 73 74 3b 20 74 68 |riginal |list; th|
|00000320| 65 20 72 65 73 75 6c 74 | 73 20 6f 66 0d 0a 20 20 |e result|s of.. |
|00000330| 20 20 20 74 68 65 20 73 | 77 61 70 20 61 72 65 20 | the s|wap are |
|00000340| 69 6e 20 63 6f 6c 75 6d | 6e 20 32 3a 0d 0a 0d 0a |in colum|n 2:....|
|00000350| 0d 0a 20 20 20 20 20 31 | 20 20 53 6d 69 74 68 20 |.. 1| Smith |
|00000360| 20 20 20 20 32 20 20 4a | 6f 6e 65 73 0d 0a 20 20 | 2 J|ones.. |
|00000370| 20 20 20 32 20 20 4a 6f | 6e 65 73 20 20 20 20 20 | 2 Jo|nes |
|00000380| 31 20 20 53 6d 69 74 68 | 0d 0a 20 20 20 20 20 33 |1 Smith|.. 3|
|00000390| 20 20 41 6d 65 73 20 20 | 20 20 20 20 33 20 20 41 | Ames | 3 A|
|000003a0| 6d 65 73 0d 0a 20 20 20 | 20 20 34 20 20 48 65 72 |mes.. | 4 Her|
|000003b0| 6d 61 6e 20 20 20 20 34 | 20 20 48 65 72 6d 61 6e |man 4| Herman|
|000003c0| 0d 0a 0d 0a 0d 0a 20 20 | 20 20 20 4e 65 78 74 20 |...... | Next |
|000003d0| 65 78 61 6d 69 6e 65 20 | 74 68 65 20 32 6e 64 20 |examine |the 2nd |
|000003e0| 61 6e 64 20 33 72 64 20 | 65 6e 74 72 69 65 73 2e |and 3rd |entries.|
|000003f0| 20 20 41 67 61 69 6e 2c | 20 69 66 20 74 68 65 20 | Again,| if the |
|00000400| 32 6e 64 20 69 73 20 6c | 61 72 67 65 72 20 74 68 |2nd is l|arger th|
|00000410| 61 6e 0d 0a 20 20 20 20 | 20 74 68 65 20 33 72 64 |an.. | the 3rd|
|00000420| 2c 20 73 77 61 70 2e 20 | 20 43 6f 6c 75 6d 6e 20 |, swap. | Column |
|00000430| 33 20 73 68 6f 77 73 20 | 74 68 65 20 72 65 73 75 |3 shows |the resu|
|00000440| 6c 74 73 3a 0d 0a 0d 0a | 0d 0a 20 20 20 20 20 31 |lts:....|.. 1|
|00000450| 20 20 53 6d 69 74 68 20 | 20 20 20 20 32 20 20 4a | Smith | 2 J|
|00000460| 6f 6e 65 73 20 20 20 20 | 20 32 20 20 4a 6f 6e 65 |ones | 2 Jone|
|00000470| 73 0d 0a 20 20 20 20 20 | 32 20 20 4a 6f 6e 65 73 |s.. |2 Jones|
|00000480| 20 20 20 20 20 31 20 20 | 53 6d 69 74 68 20 20 20 | 1 |Smith |
|00000490| 20 20 33 20 20 41 6d 65 | 73 0d 0a 20 20 20 20 20 | 3 Ame|s.. |
|000004a0| 33 20 20 41 6d 65 73 20 | 20 20 20 20 20 33 20 20 |3 Ames | 3 |
|000004b0| 41 6d 65 73 20 20 20 20 | 20 20 31 20 20 53 6d 69 |Ames | 1 Smi|
|000004c0| 74 68 0d 0a 20 20 20 20 | 20 34 20 20 48 65 72 6d |th.. | 4 Herm|
|000004d0| 61 6e 20 20 20 20 34 20 | 20 48 65 72 6d 61 6e 20 |an 4 | Herman |
|000004e0| 20 20 20 34 20 20 48 65 | 72 6d 61 6e 0d 0a 0d 0a | 4 He|rman....|
|000004f0| 0d 0a 20 20 20 20 20 52 | 65 70 65 61 74 20 74 68 |.. R|epeat th|
|00000500| 65 20 73 61 6d 65 20 70 | 72 6f 63 65 73 73 20 66 |e same p|rocess f|
|00000510| 6f 72 20 74 68 65 20 33 | 72 64 20 61 6e 64 20 34 |or the 3|rd and 4|
|00000520| 74 68 20 65 6e 74 72 69 | 65 73 2e 20 20 54 68 69 |th entri|es. Thi|
|00000530| 73 20 62 72 69 6e 67 73 | 20 79 6f 75 0d 0a 20 20 |s brings| you.. |
|00000540| 20 20 20 74 6f 20 74 68 | 65 20 65 6e 64 20 6f 66 | to th|e end of|
|00000550| 20 74 68 65 20 6c 69 73 | 74 2e 20 20 54 68 65 20 | the lis|t. The |
|00000560| 66 69 72 73 74 20 70 61 | 73 73 20 69 73 20 66 69 |first pa|ss is fi|
|00000570| 6e 69 73 68 65 64 2e 0d | 0a 0d 0a 0d 0a 20 20 20 |nished..|..... |
|00000580| 20 20 31 20 20 53 6d 69 | 74 68 20 20 20 20 20 32 | 1 Smi|th 2|
|00000590| 20 20 4a 6f 6e 65 73 20 | 20 20 20 20 32 20 20 4a | Jones | 2 J|
|000005a0| 6f 6e 65 73 20 20 20 20 | 20 32 20 20 4a 6f 6e 65 |ones | 2 Jone|
|000005b0| 73 0d 0a 20 20 20 20 20 | 32 20 20 4a 6f 6e 65 73 |s.. |2 Jones|
|000005c0| 20 20 20 20 20 31 20 20 | 53 6d 69 74 68 20 20 20 | 1 |Smith |
|000005d0| 20 20 33 20 20 41 6d 65 | 73 20 20 20 20 20 20 33 | 3 Ame|s 3|
|000005e0| 20 20 41 6d 65 73 0d 0a | 20 20 20 20 20 33 20 20 | Ames..| 3 |
|000005f0| 41 6d 65 73 20 20 20 20 | 20 20 33 20 20 41 6d 65 |Ames | 3 Ame|
|00000600| 73 20 20 20 20 20 20 31 | 20 20 53 6d 69 74 68 20 |s 1| Smith |
|00000610| 20 20 20 20 34 20 20 48 | 65 72 6d 61 6e 0d 0a 20 | 4 H|erman.. |
|00000620| 20 20 20 20 34 20 20 48 | 65 72 6d 61 6e 20 20 20 | 4 H|erman |
|00000630| 20 34 20 20 48 65 72 6d | 61 6e 20 20 20 20 34 20 | 4 Herm|an 4 |
|00000640| 20 48 65 72 6d 61 6e 20 | 20 20 20 31 20 20 53 6d | Herman | 1 Sm|
|00000650| 69 74 68 0d 0a 0d 0a 0d | 0a 20 20 20 20 20 41 74 |ith.....|. At|
|00000660| 20 74 68 65 20 65 6e 64 | 20 6f 66 20 74 68 65 20 | the end| of the |
|00000670| 70 61 73 73 2c 20 53 6d | 69 74 68 20 68 61 73 20 |pass, Sm|ith has |
|00000680| 62 75 62 62 6c 65 64 20 | 68 69 73 20 77 61 79 20 |bubbled |his way |
|00000690| 74 6f 20 74 68 65 20 62 | 6f 74 74 6f 6d 2e 20 20 |to the b|ottom. |
|000006a0| 49 6e 0d 0a 20 20 20 20 | 20 6f 74 68 65 72 20 77 |In.. | other w|
|000006b0| 6f 72 64 73 2c 20 74 68 | 65 20 6c 61 72 67 65 73 |ords, th|e larges|
|000006c0| 74 20 65 6e 74 72 79 20 | 69 6e 20 74 68 65 20 6c |t entry |in the l|
|000006d0| 69 73 74 20 69 73 20 77 | 68 65 72 65 20 69 74 20 |ist is w|here it |
|000006e0| 62 65 6c 6f 6e 67 73 2c | 20 69 6e 20 74 68 65 0d |belongs,| in the.|
|000006f0| 0a 20 20 20 20 20 6c 61 | 73 74 20 70 6f 73 69 74 |. la|st posit|
|00000700| 69 6f 6e 2e 0d 0a 0d 0a | 0d 0a 0d 0a 20 20 20 20 |ion.....|.... |
|00000710| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 1b 45 20 | | .E |
|00000720| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 1b | | .|
|00000730| 46 20 20 20 20 20 20 20 | 1b 45 20 20 39 36 0d 0a |F |.E 96..|
|00000740| 0d 0a 0c 0d 0a 0d 0a 0d | 0a 0d 0a 1b 46 20 20 20 |........|....F |
|00000750| 20 20 1b 45 43 48 41 50 | 54 45 52 20 38 1b 46 20 | .ECHAP|TER 8.F |
|00000760| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000770| 1b 45 53 4f 52 54 49 4e | 47 20 49 54 20 41 4c 4c |.ESORTIN|G IT ALL|
|00000780| 20 4f 55 54 20 20 1b 46 | 20 20 20 20 20 20 20 20 | OUT .F| |
|00000790| 20 20 20 20 20 20 20 20 | 20 1b 45 43 48 41 50 54 | | .ECHAPT|
|000007a0| 45 52 20 38 0d 0a 0d 0a | 0d 0a 20 20 20 20 20 1b |ER 8....|.. .|
|000007b0| 46 4f 75 72 20 73 65 63 | 6f 6e 64 20 70 61 73 73 |FOur sec|ond pass|
|000007c0| 20 73 74 61 72 74 73 20 | 77 69 74 68 20 74 68 65 | starts |with the|
|000007d0| 20 6c 61 73 74 20 6c 69 | 73 74 20 66 72 6f 6d 20 | last li|st from |
|000007e0| 74 68 65 20 70 72 65 76 | 69 6f 75 73 20 63 79 63 |the prev|ious cyc|
|000007f0| 6c 65 2e 20 20 41 73 0d | 0a 20 20 20 20 20 62 65 |le. As.|. be|
|00000800| 66 6f 72 65 2c 20 77 65 | 20 63 68 65 63 6b 20 28 |fore, we| check (|
|00000810| 61 6e 64 20 73 77 61 70 | 20 69 66 20 6e 65 63 65 |and swap| if nece|
|00000820| 73 73 61 72 79 29 20 74 | 68 65 20 31 73 74 20 61 |ssary) t|he 1st a|
|00000830| 6e 64 20 32 6e 64 20 65 | 6e 74 72 69 65 73 3a 0d |nd 2nd e|ntries:.|
|00000840| 0a 0d 0a 0d 0a 20 20 20 | 20 20 20 20 20 20 4a 6f |..... | Jo|
|00000850| 6e 65 73 20 20 20 20 20 | 20 20 20 41 6d 65 73 0d |nes | Ames.|
|00000860| 0a 20 20 20 20 20 20 20 | 20 20 41 6d 65 73 20 20 |. | Ames |
|00000870| 20 20 20 20 20 20 20 4a | 6f 6e 65 73 0d 0a 20 20 | J|ones.. |
|00000880| 20 20 20 20 20 20 20 48 | 65 72 6d 61 6e 20 20 20 | H|erman |
|00000890| 20 20 20 20 48 65 72 6d | 61 6e 0d 0a 20 20 20 20 | Herm|an.. |
|000008a0| 20 20 20 20 20 53 6d 69 | 74 68 20 20 20 20 20 20 | Smi|th |
|000008b0| 20 20 53 6d 69 74 68 0d | 0a 0d 0a 0d 0a 20 20 20 | Smith.|..... |
|000008c0| 20 20 45 6e 74 72 69 65 | 73 20 32 20 61 6e 64 20 | Entrie|s 2 and |
|000008d0| 33 20 63 6f 6d 65 20 6e | 65 78 74 3a 0d 0a 0d 0a |3 come n|ext:....|
|000008e0| 0d 0a 20 20 20 20 20 20 | 20 20 20 4a 6f 6e 65 73 |.. | Jones|
|000008f0| 20 20 20 20 20 20 20 20 | 41 6d 65 73 20 20 20 20 | |Ames |
|00000900| 20 20 20 20 41 6d 65 73 | 0d 0a 20 20 20 20 20 20 | Ames|.. |
|00000910| 20 20 20 41 6d 65 73 20 | 20 20 20 20 20 20 20 20 | Ames | |
|00000920| 4a 6f 6e 65 73 20 20 20 | 20 20 20 20 48 65 72 6d |Jones | Herm|
|00000930| 61 6e 0d 0a 20 20 20 20 | 20 20 20 20 20 48 65 72 |an.. | Her|
|00000940| 6d 61 6e 20 20 20 20 20 | 20 20 48 65 72 6d 61 6e |man | Herman|
|00000950| 20 20 20 20 20 20 4a 6f | 6e 65 73 0d 0a 20 20 20 | Jo|nes.. |
|00000960| 20 20 20 20 20 20 53 6d | 69 74 68 20 20 20 20 20 | Sm|ith |
|00000970| 20 20 20 53 6d 69 74 68 | 20 20 20 20 20 20 20 53 | Smith| S|
|00000980| 6d 69 74 68 0d 0a 0d 0a | 0d 0a 20 20 20 20 20 4e |mith....|.. N|
|00000990| 6f 20 6e 65 65 64 20 74 | 6f 20 63 6f 6d 70 61 72 |o need t|o compar|
|000009a0| 65 20 33 20 61 6e 64 20 | 34 2e 20 20 57 65 20 61 |e 3 and |4. We a|
|000009b0| 6c 72 65 61 64 79 20 6b | 6e 6f 77 20 74 68 61 74 |lready k|now that|
|000009c0| 20 53 6d 69 74 68 20 28 | 6e 75 6d 62 65 72 20 34 | Smith (|number 4|
|000009d0| 29 20 69 73 20 69 6e 0d | 0a 20 20 20 20 20 74 68 |) is in.|. th|
|000009e0| 65 20 63 6f 72 72 65 63 | 74 20 70 6f 73 69 74 69 |e correc|t positi|
|000009f0| 6f 6e 2e 20 20 4a 6f 6e | 65 73 2c 20 74 68 65 20 |on. Jon|es, the |
|00000a00| 6e 65 78 74 20 6c 61 72 | 67 65 73 74 20 65 6e 74 |next lar|gest ent|
|00000a10| 72 79 2c 20 69 73 20 61 | 6c 73 6f 20 69 6e 20 74 |ry, is a|lso in t|
|00000a20| 68 65 0d 0a 20 20 20 20 | 20 63 6f 72 72 65 63 74 |he.. | correct|
|00000a30| 20 6c 6f 63 61 74 69 6f | 6e 20 6e 6f 77 2e 20 20 | locatio|n now. |
|00000a40| 54 69 6d 65 20 66 6f 72 | 20 74 68 65 20 6e 65 78 |Time for| the nex|
|00000a50| 74 20 70 61 73 73 2e 0d | 0a 0d 0a 20 20 20 20 20 |t pass..|... |
|00000a60| 4f 75 72 20 73 6f 72 74 | 20 74 65 63 68 6e 69 71 |Our sort| techniq|
|00000a70| 75 65 20 63 6f 6e 73 69 | 73 74 73 20 6f 66 20 73 |ue consi|sts of s|
|00000a80| 74 61 72 74 69 6e 67 20 | 61 74 20 74 68 65 20 62 |tarting |at the b|
|00000a90| 65 67 69 6e 6e 69 6e 67 | 20 6f 66 20 61 20 6c 69 |eginning| of a li|
|00000aa0| 73 74 20 61 6e 64 0d 0a | 20 20 20 20 20 63 6f 6d |st and..| com|
|00000ab0| 70 61 72 69 6e 67 20 74 | 68 65 20 66 69 72 73 74 |paring t|he first|
|00000ac0| 20 74 77 6f 20 69 74 65 | 6d 73 2e 20 20 49 66 20 | two ite|ms. If |
|00000ad0| 74 68 65 20 66 69 72 73 | 74 20 69 73 20 6c 61 72 |the firs|t is lar|
|00000ae0| 67 65 72 20 74 68 61 6e | 20 74 68 65 20 73 65 63 |ger than| the sec|
|00000af0| 6f 6e 64 2c 0d 0a 20 20 | 20 20 20 77 65 20 73 77 |ond,.. | we sw|
|00000b00| 61 70 2e 20 20 54 68 65 | 6e 20 77 65 20 65 78 61 |ap. The|n we exa|
|00000b10| 6d 69 6e 65 20 74 68 65 | 20 6e 65 78 74 20 74 77 |mine the| next tw|
|00000b20| 6f 20 28 73 65 63 6f 6e | 64 20 61 6e 64 20 74 68 |o (secon|d and th|
|00000b30| 69 72 64 29 20 69 74 65 | 6d 73 20 61 6e 64 0d 0a |ird) ite|ms and..|
|00000b40| 20 20 20 20 20 72 65 70 | 65 61 74 20 74 68 65 20 | rep|eat the |
|00000b50| 70 72 6f 63 65 73 73 2e | 20 20 54 68 69 73 20 63 |process.| This c|
|00000b60| 6f 6e 74 69 6e 75 65 73 | 20 75 6e 74 69 6c 20 74 |ontinues| until t|
|00000b70| 68 65 20 6e 65 78 74 2d | 74 6f 2d 6c 61 73 74 20 |he next-|to-last |
|00000b80| 65 6e 74 72 79 20 68 61 | 73 0d 0a 20 20 20 20 20 |entry ha|s.. |
|00000b90| 62 65 65 6e 20 74 65 73 | 74 65 64 20 61 67 61 69 |been tes|ted agai|
|00000ba0| 6e 73 74 20 74 68 65 20 | 6c 61 73 74 20 65 6e 74 |nst the |last ent|
|00000bb0| 72 79 2e 20 20 57 68 65 | 6e 20 74 68 65 20 66 69 |ry. Whe|n the fi|
|00000bc0| 72 73 74 20 70 61 73 73 | 20 69 73 20 64 6f 6e 65 |rst pass| is done|
|00000bd0| 2c 20 74 68 65 0d 0a 20 | 20 20 20 20 6c 61 72 67 |, the.. | larg|
|00000be0| 65 73 74 20 65 6e 74 72 | 79 20 69 73 20 61 74 20 |est entr|y is at |
|00000bf0| 74 68 65 20 65 6e 64 20 | 6f 66 20 74 68 65 20 6c |the end |of the l|
|00000c00| 69 73 74 2e 0d 0a 0d 0a | 20 20 20 20 20 4f 6e 20 |ist.....| On |
|00000c10| 74 68 65 20 73 65 63 6f | 6e 64 20 70 61 73 73 2c |the seco|nd pass,|
|00000c20| 20 77 65 20 72 65 70 65 | 61 74 20 74 68 65 20 70 | we repe|at the p|
|00000c30| 72 6f 63 65 73 73 20 74 | 65 73 74 69 6e 67 20 65 |rocess t|esting e|
|00000c40| 61 63 68 20 65 6e 74 72 | 79 20 65 78 63 65 70 74 |ach entr|y except|
|00000c50| 20 74 68 65 0d 0a 20 20 | 20 20 20 6c 61 73 74 20 | the.. | last |
|00000c60| 6f 6e 65 2e 20 20 54 68 | 61 74 20 73 75 63 6b 65 |one. Th|at sucke|
|00000c70| 72 20 69 73 20 61 6c 72 | 65 61 64 79 20 69 6e 20 |r is alr|eady in |
|00000c80| 70 6c 61 63 65 2e 20 20 | 54 68 65 20 73 65 63 6f |place. |The seco|
|00000c90| 6e 64 20 70 61 73 73 20 | 70 75 74 73 20 74 68 65 |nd pass |puts the|
|00000ca0| 0d 0a 20 20 20 20 20 6e | 65 78 74 20 6c 61 72 67 |.. n|ext larg|
|00000cb0| 65 73 74 20 65 6e 74 72 | 79 20 77 68 65 72 65 20 |est entr|y where |
|00000cc0| 69 74 20 62 65 6c 6f 6e | 67 73 2e 20 20 54 68 65 |it belon|gs. The|
|00000cd0| 20 74 68 69 72 64 20 70 | 61 73 73 20 74 61 6b 65 | third p|ass take|
|00000ce0| 73 20 63 61 72 65 20 6f | 66 20 74 68 65 0d 0a 20 |s care o|f the.. |
|00000cf0| 20 20 20 20 74 68 69 72 | 64 20 6c 61 72 67 65 73 | thir|d larges|
|00000d00| 74 2c 20 65 74 63 2e 20 | 20 57 65 27 72 65 20 66 |t, etc. | We're f|
|00000d10| 69 6e 69 73 68 65 64 20 | 77 68 65 6e 20 74 68 65 |inished |when the|
|00000d20| 20 72 65 6d 61 69 6e 69 | 6e 67 20 6c 69 73 74 20 | remaini|ng list |
|00000d30| 69 73 20 64 6f 77 6e 20 | 74 6f 0d 0a 20 20 20 20 |is down |to.. |
|00000d40| 20 6f 6e 65 20 65 6e 74 | 72 79 20 6f 72 2c 20 77 | one ent|ry or, w|
|00000d50| 68 65 6e 20 77 65 20 6d | 61 6b 65 20 61 20 63 6f |hen we m|ake a co|
|00000d60| 6d 70 6c 65 74 65 20 70 | 61 73 73 20 77 69 74 68 |mplete p|ass with|
|00000d70| 6f 75 74 20 6d 61 6b 69 | 6e 67 20 61 6e 79 20 73 |out maki|ng any s|
|00000d80| 77 61 70 73 2e 0d 0a 0d | 0a 20 20 20 20 20 4c 65 |waps....|. Le|
|00000d90| 74 27 73 20 63 6f 64 65 | 20 69 74 2e 20 20 57 68 |t's code| it. Wh|
|00000da0| 65 72 65 3f 20 20 49 6e | 20 61 20 73 75 62 72 6f |ere? In| a subro|
|00000db0| 75 74 69 6e 65 20 6f 66 | 20 63 6f 75 72 73 65 2e |utine of| course.|
|00000dc0| 0d 0a 0d 0a 20 20 20 20 | 20 42 65 66 6f 72 65 20 |.... | Before |
|00000dd0| 77 65 20 73 74 61 72 74 | 2c 20 79 6f 75 20 73 68 |we start|, you sh|
|00000de0| 6f 75 6c 64 20 6b 6e 6f | 77 20 74 68 61 74 20 74 |ould kno|w that t|
|00000df0| 68 65 20 6f 72 69 67 69 | 6e 61 6c 20 74 61 62 6c |he origi|nal tabl|
|00000e00| 65 20 69 73 20 6e 65 76 | 65 72 0d 0a 20 20 20 20 |e is nev|er.. |
|00000e10| 20 73 6f 72 74 65 64 2e | 20 20 54 68 65 20 65 6e | sorted.| The en|
|00000e20| 74 72 69 65 73 20 61 72 | 65 20 74 72 61 6e 73 66 |tries ar|e transf|
|00000e30| 65 72 72 65 64 20 74 6f | 20 61 20 68 6f 6c 64 69 |erred to| a holdi|
|00000e40| 6e 67 20 74 61 62 6c 65 | 2c 20 48 4f 4c 44 24 28 |ng table|, HOLD$(|
|00000e50| 29 2c 20 77 68 69 63 68 | 0d 0a 20 20 20 20 20 69 |), which|.. i|
|00000e60| 73 20 73 6f 72 74 65 64 | 20 69 6e 20 74 68 65 20 |s sorted| in the |
|00000e70| 73 75 62 72 6f 75 74 69 | 6e 65 2e 20 20 54 68 69 |subrouti|ne. Thi|
|00000e80| 73 20 61 6c 6c 6f 77 73 | 20 75 73 20 74 6f 20 75 |s allows| us to u|
|00000e90| 73 65 20 74 68 65 20 73 | 61 6d 65 20 72 6f 75 74 |se the s|ame rout|
|00000ea0| 69 6e 65 20 66 6f 72 0d | 0a 20 20 20 20 20 6d 61 |ine for.|. ma|
|00000eb0| 6e 79 20 73 6f 72 74 73 | 2e 20 20 48 4f 4c 44 24 |ny sorts|. HOLD$|
|00000ec0| 28 29 20 6e 65 65 64 73 | 20 74 6f 20 62 65 20 64 |() needs| to be d|
|00000ed0| 69 6d 65 6e 73 69 6f 6e | 65 64 20 69 6e 20 74 68 |imension|ed in th|
|00000ee0| 65 20 6d 61 69 6e 20 6c | 6f 67 69 63 2e 20 20 20 |e main l|ogic. |
|00000ef0| 54 68 65 0d 0a 20 20 20 | 20 20 6d 61 69 6e 20 6c |The.. | main l|
|00000f00| 6f 67 69 63 20 6d 75 73 | 74 20 61 6c 73 6f 20 64 |ogic mus|t also d|
|00000f10| 65 66 69 6e 65 20 74 68 | 65 20 74 6f 74 61 6c 20 |efine th|e total |
|00000f20| 6e 75 6d 62 65 72 20 6f | 66 20 65 6e 74 72 69 65 |number o|f entrie|
|00000f30| 73 20 69 6e 20 74 68 65 | 20 74 61 62 6c 65 20 61 |s in the| table a|
|00000f40| 73 0d 0a 20 20 20 20 20 | 54 4f 54 2e 52 45 43 2e |s.. |TOT.REC.|
|00000f50| 20 20 41 73 20 61 6c 77 | 61 79 73 2c 20 77 65 20 | As alw|ays, we |
|00000f60| 73 74 61 72 74 20 77 69 | 74 68 20 63 6f 6d 6d 65 |start wi|th comme|
|00000f70| 6e 74 73 3a 0d 0a 0d 0a | 20 20 20 20 20 35 30 30 |nts:....| 500|
|00000f80| 30 20 27 20 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |0 ' ****|********|
|00000f90| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000fa0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000fb0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000fc0| 0d 0a 20 20 20 20 20 35 | 30 31 30 20 27 20 54 48 |.. 5|010 ' TH|
|00000fd0| 49 53 20 52 4f 55 54 49 | 4e 45 20 53 4f 52 54 53 |IS ROUTI|NE SORTS|
|00000fe0| 20 41 20 54 41 42 4c 45 | 20 57 48 49 43 48 20 48 | A TABLE| WHICH H|
|00000ff0| 41 53 20 54 4f 20 42 45 | 20 4e 41 4d 45 44 20 48 |AS TO BE| NAMED H|
|00001000| 4f 4c 44 24 28 29 20 49 | 4e 0d 0a 20 20 20 20 20 |OLD$() I|N.. |
|00001010| 35 30 32 30 20 27 20 49 | 4e 43 52 45 41 53 49 4e |5020 ' I|NCREASIN|
|00001020| 47 20 4f 52 44 45 52 2e | 20 20 54 48 45 20 54 4f |G ORDER.| THE TO|
|00001030| 54 41 4c 20 4e 55 4d 42 | 45 52 20 4f 46 20 45 4c |TAL NUMB|ER OF EL|
|00001040| 45 4d 45 4e 54 53 20 49 | 4e 20 54 48 45 20 54 41 |EMENTS I|N THE TA|
|00001050| 42 4c 45 0d 0a 20 20 20 | 20 20 35 30 33 30 20 27 |BLE.. | 5030 '|
|00001060| 20 49 53 20 41 4c 57 41 | 59 53 20 41 53 53 49 47 | IS ALWA|YS ASSIG|
|00001070| 4e 45 44 20 54 4f 20 54 | 48 45 20 56 41 52 49 41 |NED TO T|HE VARIA|
|00001080| 42 4c 45 20 27 54 4f 54 | 2e 52 45 43 27 2e 0d 0a |BLE 'TOT|.REC'...|
|00001090| 20 20 20 20 20 35 30 35 | 30 20 27 20 2a 2a 2a 2a | 505|0 ' ****|
|000010a0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000010b0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000010c0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|000010d0| 2a 2a 2a 2a 2a 2a 2a 2a | 0d 0a 20 20 20 20 20 35 |********|.. 5|
|000010e0| 30 36 30 20 27 0d 0a 0d | 0a 0d 0a 0d 0a 0d 0a 20 |060 '...|....... |
|000010f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001100| 1b 45 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.E | |
|00001110| 20 20 1b 46 20 20 20 20 | 20 20 20 1b 45 20 20 39 | .F | .E 9|
|00001120| 37 0d 0a 0d 0a 0c 0d 0a | 0d 0a 0d 0a 0d 0a 1b 46 |7.......|.......F|
|00001130| 20 20 20 20 20 1b 45 43 | 48 41 50 54 45 52 20 38 | .EC|HAPTER 8|
|00001140| 1b 46 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.F | |
|00001150| 20 20 20 1b 45 53 4f 52 | 54 49 4e 47 20 49 54 20 | .ESOR|TING IT |
|00001160| 41 4c 4c 20 4f 55 54 20 | 20 1b 46 20 20 20 20 20 |ALL OUT | .F |
|00001170| 20 20 20 20 20 20 20 20 | 20 20 20 20 1b 45 43 48 | | .ECH|
|00001180| 41 50 54 45 52 20 38 0d | 0a 0d 0a 0d 0a 20 20 20 |APTER 8.|..... |
|00001190| 20 20 1b 46 48 65 72 65 | 20 63 6f 6d 65 73 20 74 | .FHere| comes t|
|000011a0| 68 65 20 66 69 72 73 74 | 20 70 61 73 73 2c 20 65 |he first| pass, e|
|000011b0| 2e 67 2e 20 63 6f 6d 70 | 61 72 65 20 48 4f 4c 44 |.g. comp|are HOLD|
|000011c0| 24 28 31 29 20 74 6f 20 | 48 4f 4c 44 24 28 32 29 |$(1) to |HOLD$(2)|
|000011d0| 2c 20 73 77 61 70 0d 0a | 20 20 20 20 20 63 6f 6e |, swap..| con|
|000011e0| 74 65 6e 74 73 20 69 66 | 20 6e 65 63 65 73 73 61 |tents if| necessa|
|000011f0| 72 79 3b 20 63 6f 6d 70 | 61 72 65 20 48 4f 4c 44 |ry; comp|are HOLD|
|00001200| 24 28 32 29 20 74 6f 20 | 48 4f 4c 44 24 28 33 29 |$(2) to |HOLD$(3)|
|00001210| 2c 20 73 77 61 70 20 69 | 66 0d 0a 20 20 20 20 20 |, swap i|f.. |
|00001220| 6e 65 63 65 73 73 61 72 | 79 2e 2e 2e 20 20 41 74 |necessar|y... At|
|00001230| 20 74 68 65 20 73 61 6d | 65 20 74 69 6d 65 2c 20 | the sam|e time, |
|00001240| 74 72 61 63 6b 20 74 68 | 65 20 6f 63 63 75 72 72 |track th|e occurr|
|00001250| 65 6e 63 65 20 6f 66 20 | 73 77 61 70 73 20 62 79 |ence of |swaps by|
|00001260| 20 73 65 74 74 69 6e 67 | 0d 0a 20 20 20 20 20 53 | setting|.. S|
|00001270| 57 2e 46 4c 47 20 74 6f | 20 30 20 6f 75 74 73 69 |W.FLG to| 0 outsi|
|00001280| 64 65 20 74 68 65 20 6c | 6f 6f 70 20 61 6e 64 20 |de the l|oop and |
|00001290| 72 65 73 65 74 74 69 6e | 67 20 69 74 20 74 6f 20 |resettin|g it to |
|000012a0| 31 20 69 66 20 61 20 73 | 77 61 70 20 69 73 20 6d |1 if a s|wap is m|
|000012b0| 61 64 65 2e 0d 0a 0d 0a | 20 20 20 20 20 35 30 37 |ade.....| 507|
|000012c0| 30 20 53 57 2e 46 4c 47 | 20 3d 20 30 0d 0a 20 20 |0 SW.FLG| = 0.. |
|000012d0| 20 20 20 35 30 38 30 20 | 4c 41 53 54 20 20 20 3d | 5080 |LAST =|
|000012e0| 20 54 4f 54 2e 52 45 43 | 20 2d 20 31 0d 0a 20 20 | TOT.REC| - 1.. |
|000012f0| 20 20 20 35 30 39 30 20 | 27 0d 0a 20 20 20 20 20 | 5090 |'.. |
|00001300| 35 31 30 30 20 46 4f 52 | 20 4b 20 3d 20 31 20 54 |5100 FOR| K = 1 T|
|00001310| 4f 20 4c 41 53 54 0d 0a | 20 20 20 20 20 35 31 31 |O LAST..| 511|
|00001320| 30 20 27 0d 0a 20 20 20 | 20 20 35 31 32 30 20 20 |0 '.. | 5120 |
|00001330| 20 49 46 20 48 4f 4c 44 | 24 28 4b 29 20 3e 20 48 | IF HOLD|$(K) > H|
|00001340| 4f 4c 44 24 28 4b 2b 31 | 29 20 54 48 45 4e 20 53 |OLD$(K+1|) THEN S|
|00001350| 57 2e 46 4c 47 20 3d 20 | 31 3a 0d 0a 20 20 20 20 |W.FLG = |1:.. |
|00001360| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001370| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001380| 20 20 20 20 20 20 53 57 | 41 50 20 48 4f 4c 44 24 | SW|AP HOLD$|
|00001390| 28 4b 29 2c 20 48 4f 4c | 44 24 28 4b 2b 31 29 0d |(K), HOL|D$(K+1).|
|000013a0| 0a 20 20 20 20 20 35 31 | 33 30 20 27 0d 0a 20 20 |. 51|30 '.. |
|000013b0| 20 20 20 35 31 34 30 20 | 4e 45 58 54 20 4b 0d 0a | 5140 |NEXT K..|
|000013c0| 0d 0a 20 20 20 20 20 4e | 6f 74 65 2c 20 74 68 61 |.. N|ote, tha|
|000013d0| 74 20 77 65 20 73 65 74 | 20 4c 41 53 54 20 3d 20 |t we set| LAST = |
|000013e0| 54 4f 54 2e 52 45 43 2d | 31 20 61 6e 64 20 74 68 |TOT.REC-|1 and th|
|000013f0| 61 74 20 4b 20 67 6f 65 | 73 20 66 72 6f 6d 20 31 |at K goe|s from 1|
|00001400| 20 74 6f 20 4c 41 53 54 | 2e 0d 0a 20 20 20 20 20 | to LAST|... |
|00001410| 53 69 6e 63 65 20 77 65 | 20 61 6c 77 61 79 73 20 |Since we| always |
|00001420| 63 6f 6d 70 61 72 65 20 | 48 4f 4c 44 24 28 4b 29 |compare |HOLD$(K)|
|00001430| 20 74 6f 20 48 4f 4c 44 | 24 28 4b 2b 31 29 2c 20 | to HOLD|$(K+1), |
|00001440| 77 65 20 77 69 6c 6c 20 | 63 6f 6d 70 61 72 65 20 |we will |compare |
|00001450| 74 68 65 0d 0a 20 20 20 | 20 20 6e 65 78 74 2d 74 |the.. | next-t|
|00001460| 6f 2d 6c 61 73 74 20 65 | 6e 74 72 79 20 74 6f 20 |o-last e|ntry to |
|00001470| 74 68 65 20 6c 61 73 74 | 20 65 6e 74 72 79 20 6f |the last| entry o|
|00001480| 6e 20 6f 75 72 20 6c 61 | 73 74 20 28 54 4f 54 2e |n our la|st (TOT.|
|00001490| 52 45 43 2d 31 29 20 70 | 61 73 73 2e 0d 0a 0d 0a |REC-1) p|ass.....|
|000014a0| 0d 0a 20 20 20 20 20 1b | 45 53 57 41 50 0d 0a 0d |.. .|ESWAP...|
|000014b0| 0a 20 20 20 20 20 1b 46 | 54 68 65 20 6c 6f 6f 70 |. .F|The loop|
|000014c0| 20 6d 61 6b 65 73 20 6f | 6e 65 20 70 61 73 73 20 | makes o|ne pass |
|000014d0| 74 68 72 6f 75 67 68 20 | 74 68 65 20 6c 69 73 74 |through |the list|
|000014e0| 20 53 57 41 50 70 69 6e | 67 20 61 64 6a 61 63 65 | SWAPpin|g adjace|
|000014f0| 6e 74 20 65 6e 74 72 69 | 65 73 20 61 73 0d 0a 20 |nt entri|es as.. |
|00001500| 20 20 20 20 6e 65 63 65 | 73 73 61 72 79 2e 20 20 | nece|ssary. |
|00001510| 54 68 61 74 27 73 20 72 | 69 67 68 74 2c 20 74 68 |That's r|ight, th|
|00001520| 65 20 53 57 41 50 20 69 | 6e 20 6c 69 6e 65 20 35 |e SWAP i|n line 5|
|00001530| 31 32 30 20 6d 65 61 6e | 73 20 73 77 61 70 20 74 |120 mean|s swap t|
|00001540| 68 65 20 76 61 6c 75 65 | 73 20 6f 66 0d 0a 20 20 |he value|s of.. |
|00001550| 20 20 20 74 68 65 20 74 | 77 6f 20 76 61 72 69 61 | the t|wo varia|
|00001560| 62 6c 65 73 20 74 68 61 | 74 20 66 6f 6c 6c 6f 77 |bles tha|t follow|
|00001570| 2e 20 20 50 72 65 74 74 | 79 20 6e 65 61 74 20 69 |. Prett|y neat i|
|00001580| 6e 73 74 72 75 63 74 69 | 6f 6e 2c 20 69 73 6e 27 |nstructi|on, isn'|
|00001590| 74 20 69 74 3f 20 20 57 | 68 65 6e 0d 0a 20 20 20 |t it? W|hen.. |
|000015a0| 20 20 74 68 65 20 6c 6f | 6f 70 20 66 69 6e 69 73 | the lo|op finis|
|000015b0| 68 65 73 2c 20 74 68 65 | 20 6c 61 72 67 65 73 74 |hes, the| largest|
|000015c0| 20 65 6e 74 72 79 20 69 | 73 20 69 6e 20 74 68 65 | entry i|s in the|
|000015d0| 20 6c 61 73 74 20 66 69 | 6c 6c 65 64 20 74 61 62 | last fi|lled tab|
|000015e0| 6c 65 0d 0a 20 20 20 20 | 20 6c 6f 63 61 74 69 6f |le.. | locatio|
|000015f0| 6e 2e 20 20 53 57 2e 46 | 4c 47 20 69 73 20 31 20 |n. SW.F|LG is 1 |
|00001600| 69 66 20 61 20 73 77 61 | 70 20 77 61 73 20 6d 61 |if a swa|p was ma|
|00001610| 64 65 2e 0d 0a 0d 0a 20 | 20 20 20 20 57 69 74 68 |de..... | With|
|00001620| 20 6f 6e 65 20 70 61 73 | 73 20 63 6f 6d 70 6c 65 | one pas|s comple|
|00001630| 74 65 64 2c 20 77 65 20 | 73 61 6c 6c 79 20 66 6f |ted, we |sally fo|
|00001640| 72 74 68 20 66 6f 72 20 | 74 68 65 20 6e 65 78 74 |rth for |the next|
|00001650| 20 70 61 73 73 2e 20 20 | 57 65 20 6b 6e 6f 77 20 | pass. |We know |
|00001660| 74 68 65 0d 0a 20 20 20 | 20 20 6c 61 73 74 20 6c |the.. | last l|
|00001670| 6f 63 61 74 69 6f 6e 20 | 69 73 20 63 6f 72 72 65 |ocation |is corre|
|00001680| 63 74 20 73 6f 20 77 65 | 20 64 65 63 72 65 61 73 |ct so we| decreas|
|00001690| 65 20 4c 41 53 54 20 62 | 79 20 31 2e 20 20 4c 65 |e LAST b|y 1. Le|
|000016a0| 61 76 65 20 74 68 61 74 | 20 6c 6f 63 61 74 69 6f |ave that| locatio|
|000016b0| 6e 0d 0a 20 20 20 20 20 | 61 6c 6f 6e 65 2e 20 20 |n.. |alone. |
|000016c0| 54 68 65 6e 20 77 65 20 | 67 6f 20 74 6f 20 74 68 |Then we |go to th|
|000016d0| 65 20 57 48 49 4c 45 20 | 73 74 61 74 65 6d 65 6e |e WHILE |statemen|
|000016e0| 74 20 74 6f 20 63 68 65 | 63 6b 20 77 68 65 74 68 |t to che|ck wheth|
|000016f0| 65 72 20 61 6e 6f 74 68 | 65 72 20 70 61 73 73 0d |er anoth|er pass.|
|00001700| 0a 20 20 20 20 20 69 73 | 20 6e 65 65 64 65 64 2e |. is| needed.|
|00001710| 20 20 49 66 20 74 68 65 | 20 61 6e 73 77 65 72 20 | If the| answer |
|00001720| 69 73 20 79 65 73 2c 20 | 74 68 65 20 73 77 61 70 |is yes, |the swap|
|00001730| 20 66 6c 61 67 20 69 73 | 20 72 65 73 65 74 20 61 | flag is| reset a|
|00001740| 6e 64 20 77 65 27 72 65 | 20 6f 66 66 2e 0d 0a 20 |nd we're| off... |
|00001750| 20 20 20 20 4c 65 74 27 | 73 20 6d 6f 64 69 66 79 | Let'|s modify|
|00001760| 20 6f 75 72 20 63 6f 64 | 65 20 74 6f 20 68 61 6e | our cod|e to han|
|00001770| 64 6c 65 20 74 68 69 73 | 20 73 74 75 66 66 3a 0d |dle this| stuff:.|
|00001780| 0a 0d 0a 20 20 20 20 20 | 35 30 37 30 20 53 57 2e |... |5070 SW.|
|00001790| 46 4c 47 20 3d 20 31 20 | 20 20 20 20 20 20 20 20 |FLG = 1 | |
|000017a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000017b0| 20 20 20 20 20 20 20 20 | 20 27 53 45 54 20 46 4c | | 'SET FL|
|000017c0| 41 47 20 54 4f 20 4e 4f | 20 53 57 41 50 0d 0a 20 |AG TO NO| SWAP.. |
|000017d0| 20 20 20 20 35 30 38 30 | 20 4c 41 53 54 20 20 20 | 5080| LAST |
|000017e0| 3d 20 54 4f 54 2e 52 45 | 43 20 2d 20 31 20 20 20 |= TOT.RE|C - 1 |
|000017f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001800| 20 20 20 20 20 20 20 27 | 45 4e 44 20 4f 46 20 46 | '|END OF F|
|00001810| 49 52 53 54 20 50 41 53 | 53 0d 0a 20 20 20 20 20 |IRST PAS|S.. |
|00001820| 35 30 39 30 20 27 0d 0a | 20 20 20 20 20 35 31 30 |5090 '..| 510|
|00001830| 30 20 57 48 49 4c 45 20 | 4c 41 53 54 20 3c 3e 20 |0 WHILE |LAST <> |
|00001840| 30 20 41 4e 44 20 53 57 | 2e 46 4c 47 20 3c 3e 20 |0 AND SW|.FLG <> |
|00001850| 30 20 20 20 20 20 20 20 | 20 20 20 20 20 20 27 53 |0 | 'S|
|00001860| 54 41 52 54 20 53 4f 52 | 54 0d 0a 20 20 20 20 20 |TART SOR|T.. |
|00001870| 35 31 31 30 20 27 0d 0a | 20 20 20 20 20 35 31 32 |5110 '..| 512|
|00001880| 30 20 20 20 20 53 57 2e | 46 4c 47 20 3d 20 30 20 |0 SW.|FLG = 0 |
|00001890| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000018a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 27 52 | | 'R|
|000018b0| 45 53 45 54 20 50 52 45 | 56 49 4f 55 53 20 50 41 |ESET PRE|VIOUS PA|
|000018c0| 53 53 0d 0a 20 20 20 20 | 20 35 31 33 30 20 27 0d |SS.. | 5130 '.|
|000018d0| 0a 20 20 20 20 20 35 31 | 34 30 20 20 20 20 46 4f |. 51|40 FO|
|000018e0| 52 20 4b 20 3d 20 31 20 | 54 4f 20 4c 41 53 54 20 |R K = 1 |TO LAST |
|000018f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001900| 20 20 20 20 20 20 20 27 | 44 4f 20 4f 4e 45 20 50 | '|DO ONE P|
|00001910| 41 53 53 0d 0a 20 20 20 | 20 20 35 31 35 30 20 20 |ASS.. | 5150 |
|00001920| 20 20 20 20 49 46 20 48 | 4f 4c 44 24 28 4b 29 20 | IF H|OLD$(K) |
|00001930| 3e 20 48 4f 4c 44 24 28 | 4b 2b 31 29 20 54 48 45 |> HOLD$(|K+1) THE|
|00001940| 4e 20 53 57 2e 46 4c 47 | 20 3d 20 31 3a 0d 0a 20 |N SW.FLG| = 1:.. |
|00001950| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001960| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001970| 20 20 20 20 20 20 20 20 | 20 20 20 20 53 57 41 50 | | SWAP|
|00001980| 20 48 4f 4c 44 24 28 4b | 29 2c 20 48 4f 4c 44 24 | HOLD$(K|), HOLD$|
|00001990| 28 4b 2b 31 29 0d 0a 20 | 20 20 20 20 35 31 36 30 |(K+1).. | 5160|
|000019a0| 20 20 20 20 4e 45 58 54 | 20 4b 0d 0a 20 20 20 20 | NEXT| K.. |
|000019b0| 20 35 31 37 30 20 27 0d | 0a 20 20 20 20 20 35 31 | 5170 '.|. 51|
|000019c0| 38 30 20 20 20 20 4c 41 | 53 54 20 3d 20 4c 41 53 |80 LA|ST = LAS|
|000019d0| 54 20 2d 20 31 20 20 20 | 20 20 20 20 20 20 20 20 |T - 1 | |
|000019e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 27 | | '|
|000019f0| 44 45 43 52 45 4d 45 4e | 54 20 4c 4f 4f 50 20 4c |DECREMEN|T LOOP L|
|00001a00| 49 4d 49 54 0d 0a 20 20 | 20 20 20 35 31 39 30 20 |IMIT.. | 5190 |
|00001a10| 27 0d 0a 20 20 20 20 20 | 35 32 30 30 20 57 45 4e |'.. |5200 WEN|
|00001a20| 44 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |D | |
|00001a30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001a40| 20 20 20 20 20 20 20 20 | 20 27 47 4f 20 41 4e 44 | | 'GO AND|
|00001a50| 20 4d 41 4b 45 20 41 4e | 4f 54 48 45 52 0d 0a 20 | MAKE AN|OTHER.. |
|00001a60| 20 20 20 20 35 32 31 30 | 20 27 20 20 20 20 20 20 | 5210| ' |
|00001a70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001a80| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001a90| 20 20 20 20 20 20 50 41 | 53 53 20 49 53 20 4e 45 | PA|SS IS NE|
|00001aa0| 43 45 53 53 41 52 59 0d | 0a 0d 0a 0d 0a 0d 0a 0d |CESSARY.|........|
|00001ab0| 0a 0d 0a 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |... | |
|00001ac0| 20 20 20 20 1b 45 20 20 | 20 20 20 20 20 20 20 20 | .E | |
|00001ad0| 20 20 20 20 20 20 1b 46 | 20 20 20 20 20 20 20 1b | .F| .|
|00001ae0| 45 20 20 39 38 0d 0a 0d | 0a 0c 0d 0a 0d 0a 0d 0a |E 98...|........|
|00001af0| 0d 0a 1b 46 20 20 20 20 | 20 1b 45 43 48 41 50 54 |...F | .ECHAPT|
|00001b00| 45 52 20 38 1b 46 20 20 | 20 20 20 20 20 20 20 20 |ER 8.F | |
|00001b10| 20 20 20 20 20 20 20 1b | 45 53 4f 52 54 49 4e 47 | .|ESORTING|
|00001b20| 20 49 54 20 41 4c 4c 20 | 4f 55 54 20 20 1b 46 20 | IT ALL |OUT .F |
|00001b30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001b40| 1b 45 43 48 41 50 54 45 | 52 20 38 0d 0a 0d 0a 0d |.ECHAPTE|R 8.....|
|00001b50| 0a 20 20 20 20 20 1b 46 | 4e 6f 74 65 20 74 68 61 |. .F|Note tha|
|00001b60| 74 20 77 65 20 73 74 61 | 72 74 65 64 20 77 69 74 |t we sta|rted wit|
|00001b70| 68 20 53 57 2e 46 4c 47 | 20 3d 20 31 2e 20 20 41 |h SW.FLG| = 1. A|
|00001b80| 20 6e 6f 6e 2d 7a 65 72 | 6f 20 76 61 6c 75 65 20 | non-zer|o value |
|00001b90| 69 73 20 72 65 71 75 69 | 72 65 64 20 74 6f 0d 0a |is requi|red to..|
|00001ba0| 20 20 20 20 20 67 65 74 | 20 69 6e 74 6f 20 74 68 | get| into th|
|00001bb0| 65 20 57 48 49 4c 45 20 | 6c 6f 6f 70 20 73 69 6e |e WHILE |loop sin|
|00001bc0| 63 65 20 6f 6e 65 20 6f | 66 20 74 68 65 20 63 6f |ce one o|f the co|
|00001bd0| 6e 64 69 74 69 6f 6e 73 | 20 74 68 61 74 20 69 74 |nditions| that it|
|00001be0| 20 74 65 73 74 73 20 66 | 6f 72 20 69 73 0d 0a 20 | tests f|or is.. |
|00001bf0| 20 20 20 20 53 57 2e 46 | 4c 47 20 3c 3e 20 30 2e | SW.F|LG <> 0.|
|00001c00| 20 20 53 57 2e 46 4c 47 | 20 69 73 20 69 6e 69 74 | SW.FLG| is init|
|00001c10| 69 61 6c 69 7a 65 64 20 | 74 6f 20 30 20 28 6e 6f |ialized |to 0 (no|
|00001c20| 20 73 77 61 70 29 20 69 | 6e 73 69 64 65 20 74 68 | swap) i|nside th|
|00001c30| 65 20 57 48 49 4c 45 20 | 61 6e 64 0d 0a 20 20 20 |e WHILE |and.. |
|00001c40| 20 20 62 65 66 6f 72 65 | 20 74 68 65 20 46 4f 52 | before| the FOR|
|00001c50| 2f 4e 45 58 54 20 6c 6f | 6f 70 2e 0d 0a 0d 0a 20 |/NEXT lo|op..... |
|00001c60| 20 20 20 20 54 68 65 20 | 63 6f 6d 70 6c 65 74 65 | The |complete|
|00001c70| 20 73 75 62 72 6f 75 74 | 69 6e 65 20 69 73 20 6e | subrout|ine is n|
|00001c80| 6f 77 20 61 73 20 66 6f | 6c 6c 6f 77 73 3a 0d 0a |ow as fo|llows:..|
|00001c90| 0d 0a 20 20 20 20 20 35 | 30 30 30 20 27 20 2a 2a |.. 5|000 ' **|
|00001ca0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00001cb0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00001cc0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00001cd0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 0d 0a 20 20 20 20 |********|**.. |
|00001ce0| 20 35 30 31 30 20 27 20 | 54 48 49 53 20 52 4f 55 | 5010 ' |THIS ROU|
|00001cf0| 54 49 4e 45 20 53 4f 52 | 54 53 20 41 20 54 41 42 |TINE SOR|TS A TAB|
|00001d00| 4c 45 20 57 48 49 43 48 | 20 48 41 53 20 54 4f 20 |LE WHICH| HAS TO |
|00001d10| 42 45 20 4e 41 4d 45 44 | 20 48 4f 4c 44 24 28 29 |BE NAMED| HOLD$()|
|00001d20| 20 49 4e 0d 0a 20 20 20 | 20 20 35 30 32 30 20 27 | IN.. | 5020 '|
|00001d30| 20 49 4e 43 52 45 41 53 | 49 4e 47 20 4f 52 44 45 | INCREAS|ING ORDE|
|00001d40| 52 2e 20 20 54 48 45 20 | 54 4f 54 41 4c 20 4e 55 |R. THE |TOTAL NU|
|00001d50| 4d 42 45 52 20 4f 46 20 | 45 4c 45 4d 45 4e 54 53 |MBER OF |ELEMENTS|
|00001d60| 20 49 4e 20 54 48 45 20 | 54 41 42 4c 45 0d 0a 20 | IN THE |TABLE.. |
|00001d70| 20 20 20 20 35 30 33 30 | 20 27 20 49 53 20 41 4c | 5030| ' IS AL|
|00001d80| 57 41 59 53 20 41 53 53 | 49 47 4e 45 44 20 54 4f |WAYS ASS|IGNED TO|
|00001d90| 20 54 48 45 20 56 41 52 | 49 41 42 4c 45 20 27 54 | THE VAR|IABLE 'T|
|00001da0| 4f 54 2e 52 45 43 27 2e | 0d 0a 20 20 20 20 20 35 |OT.REC'.|.. 5|
|00001db0| 30 35 30 20 27 20 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |050 ' **|********|
|00001dc0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00001dd0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00001de0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00001df0| 2a 2a 0d 0a 20 20 20 20 | 20 35 30 36 30 20 27 0d |**.. | 5060 '.|
|00001e00| 0a 20 20 20 20 20 35 30 | 37 30 20 53 57 2e 46 4c |. 50|70 SW.FL|
|00001e10| 47 20 3d 20 31 20 20 20 | 20 20 20 20 20 20 20 20 |G = 1 | |
|00001e20| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001e30| 20 20 20 20 20 20 20 27 | 53 45 54 20 46 4c 41 47 | '|SET FLAG|
|00001e40| 20 54 4f 20 4e 4f 20 53 | 57 41 50 0d 0a 20 20 20 | TO NO S|WAP.. |
|00001e50| 20 20 35 30 38 30 20 4c | 41 53 54 20 20 20 3d 20 | 5080 L|AST = |
|00001e60| 54 4f 54 2e 52 45 43 20 | 2d 20 31 20 20 20 20 20 |TOT.REC |- 1 |
|00001e70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001e80| 20 20 20 27 45 4e 44 20 | 4f 46 20 46 49 52 53 54 | 'END |OF FIRST|
|00001e90| 20 50 41 53 53 0d 0a 20 | 20 20 20 20 35 30 39 30 | PASS.. | 5090|
|00001ea0| 20 27 0d 0a 20 20 20 20 | 20 35 31 30 30 20 57 48 | '.. | 5100 WH|
|00001eb0| 49 4c 45 20 4c 41 53 54 | 20 3c 3e 20 30 20 20 41 |ILE LAST| <> 0 A|
|00001ec0| 4e 44 20 20 53 57 2e 46 | 4c 47 20 3c 3e 20 30 20 |ND SW.F|LG <> 0 |
|00001ed0| 20 20 20 20 20 20 20 20 | 20 20 27 53 54 41 52 54 | | 'START|
|00001ee0| 20 53 4f 52 54 0d 0a 20 | 20 20 20 20 35 31 31 30 | SORT.. | 5110|
|00001ef0| 20 27 0d 0a 20 20 20 20 | 20 35 31 32 30 20 20 20 | '.. | 5120 |
|00001f00| 20 53 57 2e 46 4c 47 20 | 3d 20 30 20 20 20 20 20 | SW.FLG |= 0 |
|00001f10| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001f20| 20 20 20 20 20 20 20 20 | 20 20 27 52 45 53 45 54 | | 'RESET|
|00001f30| 20 50 52 45 56 49 4f 55 | 53 20 50 41 53 53 0d 0a | PREVIOU|S PASS..|
|00001f40| 20 20 20 20 20 35 31 33 | 30 20 27 0d 0a 20 20 20 | 513|0 '.. |
|00001f50| 20 20 35 31 34 30 20 20 | 20 20 46 4f 52 20 4b 20 | 5140 | FOR K |
|00001f60| 3d 20 31 20 54 4f 20 4c | 41 53 54 20 20 20 20 20 |= 1 TO L|AST |
|00001f70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001f80| 20 20 20 27 44 4f 20 4f | 4e 45 20 50 41 53 53 0d | 'DO O|NE PASS.|
|00001f90| 0a 20 20 20 20 20 35 31 | 35 30 20 20 20 20 20 20 |. 51|50 |
|00001fa0| 49 46 20 48 4f 4c 44 24 | 28 4b 29 20 3e 20 48 4f |IF HOLD$|(K) > HO|
|00001fb0| 4c 44 24 28 4b 2b 31 29 | 20 54 48 45 4e 20 53 57 |LD$(K+1)| THEN SW|
|00001fc0| 2e 46 4c 47 20 3d 20 31 | 3a 0d 0a 20 20 20 20 20 |.FLG = 1|:.. |
|00001fd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001fe0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001ff0| 20 20 20 20 20 20 20 20 | 53 57 41 50 20 48 4f 4c | |SWAP HOL|
|00002000| 44 24 28 4b 29 2c 20 48 | 4f 4c 44 24 28 4b 2b 31 |D$(K), H|OLD$(K+1|
|00002010| 29 0d 0a 20 20 20 20 20 | 35 31 36 30 20 20 20 20 |).. |5160 |
|00002020| 4e 45 58 54 20 4b 0d 0a | 20 20 20 20 20 35 31 37 |NEXT K..| 517|
|00002030| 30 20 27 0d 0a 20 20 20 | 20 20 35 31 38 30 20 20 |0 '.. | 5180 |
|00002040| 20 20 4c 41 53 54 20 3d | 20 4c 41 53 54 20 2d 20 | LAST =| LAST - |
|00002050| 31 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |1 | |
|00002060| 20 20 20 20 20 20 20 20 | 20 20 20 27 44 45 43 52 | | 'DECR|
|00002070| 45 4d 45 4e 54 20 4c 4f | 4f 50 20 4c 49 4d 49 54 |EMENT LO|OP LIMIT|
|00002080| 0d 0a 20 20 20 20 20 35 | 31 39 30 20 27 0d 0a 20 |.. 5|190 '.. |
|00002090| 20 20 20 20 35 32 30 30 | 20 57 45 4e 44 20 20 20 | 5200| WEND |
|000020a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000020b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000020c0| 20 20 20 20 20 27 47 4f | 20 41 4e 44 20 4d 41 4b | 'GO| AND MAK|
|000020d0| 45 20 41 4e 4f 54 48 45 | 52 0d 0a 20 20 20 20 20 |E ANOTHE|R.. |
|000020e0| 35 32 31 30 20 27 20 20 | 20 20 20 20 20 20 20 20 |5210 ' | |
|000020f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002100| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002110| 20 20 50 41 53 53 20 49 | 53 20 4e 45 43 45 53 53 | PASS I|S NECESS|
|00002120| 41 52 59 0d 0a 20 20 20 | 20 20 35 32 32 30 20 52 |ARY.. | 5220 R|
|00002130| 45 54 55 52 4e 0d 0a 0d | 0a 0d 0a 20 20 20 20 20 |ETURN...|... |
|00002140| 48 65 72 65 20 61 72 65 | 20 73 6f 6d 65 20 74 68 |Here are| some th|
|00002150| 69 6e 67 73 20 79 6f 75 | 20 6e 65 65 64 20 74 6f |ings you| need to|
|00002160| 20 6b 6e 6f 77 20 61 62 | 6f 75 74 20 74 68 65 20 | know ab|out the |
|00002170| 73 6f 72 74 20 77 65 27 | 76 65 20 63 6f 64 65 64 |sort we'|ve coded|
|00002180| 3a 0d 0a 0d 0a 20 20 20 | 20 20 2d 20 20 49 74 20 |:.... | - It |
|00002190| 69 73 20 6e 6f 74 20 61 | 20 76 65 72 79 20 65 66 |is not a| very ef|
|000021a0| 66 69 63 69 65 6e 74 20 | 72 6f 75 74 69 6e 65 2e |ficient |routine.|
|000021b0| 20 20 57 65 20 75 73 65 | 20 69 74 20 68 65 72 65 | We use| it here|
|000021c0| 20 62 65 63 61 75 73 65 | 20 69 74 0d 0a 20 20 20 | because| it.. |
|000021d0| 20 20 20 20 20 69 73 20 | 74 68 65 20 65 61 73 69 | is |the easi|
|000021e0| 65 73 74 20 6f 6e 65 20 | 74 6f 20 75 6e 64 65 72 |est one |to under|
|000021f0| 73 74 61 6e 64 20 61 6e | 64 20 70 72 6f 67 72 61 |stand an|d progra|
|00002200| 6d 2e 20 20 49 66 20 79 | 6f 75 20 72 65 61 6c 6c |m. If y|ou reall|
|00002210| 79 20 6e 65 65 64 20 61 | 0d 0a 20 20 20 20 20 20 |y need a|.. |
|00002220| 20 20 72 6f 75 74 69 6e | 65 20 66 6f 72 20 61 20 | routin|e for a |
|00002230| 70 72 6f 64 75 63 74 69 | 6f 6e 20 50 43 20 70 72 |producti|on PC pr|
|00002240| 6f 67 72 61 6d 2c 20 74 | 68 65 72 65 20 61 72 65 |ogram, t|here are|
|00002250| 20 62 65 74 74 65 72 20 | 6f 6e 65 73 20 61 72 6f | better |ones aro|
|00002260| 75 6e 64 2e 0d 0a 20 20 | 20 20 20 20 20 20 4f 6e |und... | On|
|00002270| 20 74 68 65 20 6d 61 69 | 6e 66 72 61 6d 65 2c 20 | the mai|nframe, |
|00002280| 73 6f 72 74 20 72 6f 75 | 74 69 6e 65 73 20 61 72 |sort rou|tines ar|
|00002290| 65 20 6e 6f 72 6d 61 6c | 6c 79 20 61 76 61 69 6c |e normal|ly avail|
|000022a0| 61 62 6c 65 20 61 73 20 | 73 74 61 6e 64 61 72 64 |able as |standard|
|000022b0| 0d 0a 20 20 20 20 20 20 | 20 20 75 74 69 6c 69 74 |.. | utilit|
|000022c0| 69 65 73 2e 0d 0a 0d 0a | 20 20 20 20 20 2d 20 20 |ies.....| - |
|000022d0| 54 68 65 20 72 6f 75 74 | 69 6e 65 20 77 6f 72 6b |The rout|ine work|
|000022e0| 73 20 66 6f 72 20 74 61 | 62 6c 65 73 20 6f 66 20 |s for ta|bles of |
|000022f0| 73 74 72 69 6e 67 73 2e | 20 20 49 74 20 77 69 6c |strings.| It wil|
|00002300| 6c 20 6e 6f 74 20 68 61 | 6e 64 6c 65 20 6e 75 6d |l not ha|ndle num|
|00002310| 62 65 72 73 0d 0a 20 20 | 20 20 20 20 20 20 76 65 |bers.. | ve|
|00002320| 72 79 20 77 65 6c 6c 2e | 20 20 41 20 6e 75 6d 65 |ry well.| A nume|
|00002330| 72 69 63 20 73 6f 72 74 | 20 72 6f 75 74 69 6e 65 |ric sort| routine|
|00002340| 20 77 6f 75 6c 64 20 75 | 73 65 20 48 4f 4c 44 28 | would u|se HOLD(|
|00002350| 29 20 61 73 20 61 20 74 | 61 62 6c 65 2e 0d 0a 0d |) as a t|able....|
|00002360| 0a 20 20 20 20 20 2d 20 | 20 54 68 65 20 72 6f 75 |. - | The rou|
|00002370| 74 69 6e 65 20 63 61 6e | 20 62 65 20 6d 61 64 65 |tine can| be made|
|00002380| 20 74 6f 20 73 6f 72 74 | 20 69 6e 20 64 65 63 72 | to sort| in decr|
|00002390| 65 61 73 69 6e 67 20 6f | 72 64 65 72 20 62 79 20 |easing o|rder by |
|000023a0| 63 68 61 6e 67 69 6e 67 | 20 6c 69 6e 65 0d 0a 20 |changing| line.. |
|000023b0| 20 20 20 20 20 20 20 35 | 31 35 30 20 74 6f 3a 0d | 5|150 to:.|
|000023c0| 0a 0d 0a 20 20 20 20 20 | 20 20 20 35 31 35 30 20 |... | 5150 |
|000023d0| 20 20 20 20 20 49 46 20 | 48 4f 4c 44 24 28 4b 29 | IF |HOLD$(K)|
|000023e0| 20 3c 20 48 4f 4c 44 24 | 28 4b 2b 31 29 20 54 48 | < HOLD$|(K+1) TH|
|000023f0| 45 4e 20 53 57 2e 46 4c | 47 20 3d 20 31 3a 0d 0a |EN SW.FL|G = 1:..|
|00002400| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002410| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002420| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002430| 53 57 41 50 20 48 4f 4c | 44 24 28 4b 29 2c 20 48 |SWAP HOL|D$(K), H|
|00002440| 4f 4c 44 24 28 4b 2b 31 | 29 0d 0a 0d 0a 20 20 20 |OLD$(K+1|).... |
|00002450| 20 20 2d 20 20 54 4f 54 | 2e 52 45 43 20 61 6e 64 | - TOT|.REC and|
|00002460| 20 48 4f 4c 44 24 28 29 | 20 6d 75 73 74 20 61 6c | HOLD$()| must al|
|00002470| 77 61 79 73 20 62 65 20 | 64 65 66 69 6e 65 64 20 |ways be |defined |
|00002480| 69 6e 20 79 6f 75 72 20 | 6d 61 69 6e 20 6c 6f 67 |in your |main log|
|00002490| 69 63 2e 0d 0a 20 20 20 | 20 20 20 20 20 54 68 65 |ic... | The|
|000024a0| 20 76 61 72 69 61 62 6c | 65 20 6e 61 6d 65 20 66 | variabl|e name f|
|000024b0| 6f 72 20 74 68 65 20 74 | 6f 74 61 6c 20 65 6e 74 |or the t|otal ent|
|000024c0| 72 69 65 73 20 69 73 20 | 61 6c 77 61 79 73 20 54 |ries is |always T|
|000024d0| 4f 54 2e 52 45 43 2e 0d | 0a 0d 0a 0d 0a 0d 0a 0d |OT.REC..|........|
|000024e0| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | |
|000024f0| 20 20 1b 45 20 20 20 20 | 20 20 20 20 20 20 20 20 | .E | |
|00002500| 20 20 20 20 1b 46 20 20 | 20 20 20 20 20 1b 45 20 | .F | .E |
|00002510| 20 39 39 0d 0a 0d 0a 0c | 0d 0a 0d 0a 0d 0a 0d 0a | 99.....|........|
|00002520| 1b 46 20 20 20 20 20 1b | 45 43 48 41 50 54 45 52 |.F .|ECHAPTER|
|00002530| 20 38 1b 46 20 20 20 20 | 20 20 20 20 20 20 20 20 | 8.F | |
|00002540| 20 20 20 20 20 1b 45 53 | 4f 52 54 49 4e 47 20 49 | .ES|ORTING I|
|00002550| 54 20 41 4c 4c 20 4f 55 | 54 20 20 1b 46 20 20 20 |T ALL OU|T .F |
|00002560| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 1b 45 | | .E|
|00002570| 43 48 41 50 54 45 52 20 | 38 0d 0a 0d 0a 0d 0a 20 |CHAPTER |8...... |
|00002580| 20 20 20 20 1b 46 54 68 | 61 74 27 73 20 6f 75 72 | .FTh|at's our|
|00002590| 20 73 6f 72 74 2e 20 20 | 48 65 72 65 27 73 20 61 | sort. |Here's a|
|000025a0| 20 70 72 6f 67 72 61 6d | 20 74 6f 20 73 68 6f 77 | program| to show|
|000025b0| 20 79 6f 75 20 68 6f 77 | 20 74 6f 20 75 73 65 20 | you how| to use |
|000025c0| 69 74 3a 0d 0a 0d 0a 20 | 20 20 20 20 31 30 30 20 |it:.... | 100 |
|000025d0| 44 49 4d 20 50 45 52 53 | 4f 4e 24 28 35 30 29 2c |DIM PERS|ON$(50),|
|000025e0| 48 4f 4c 44 24 28 35 30 | 29 0d 0a 20 20 20 20 20 |HOLD$(50|).. |
|000025f0| 31 31 30 20 49 4e 50 55 | 54 20 22 48 6f 77 20 6d |110 INPU|T "How m|
|00002600| 61 6e 79 20 6e 61 6d 65 | 73 20 64 6f 20 77 65 20 |any name|s do we |
|00002610| 65 6e 74 65 72 22 3b 20 | 54 4f 54 2e 52 45 43 0d |enter"; |TOT.REC.|
|00002620| 0a 20 20 20 20 20 31 32 | 30 20 27 0d 0a 20 20 20 |. 12|0 '.. |
|00002630| 20 20 31 33 30 20 46 4f | 52 20 49 3d 31 20 54 4f | 130 FO|R I=1 TO|
|00002640| 20 54 4f 54 2e 52 45 43 | 0d 0a 20 20 20 20 20 31 | TOT.REC|.. 1|
|00002650| 34 30 20 20 20 49 4e 50 | 55 54 20 22 47 69 6d 6d |40 INP|UT "Gimm|
|00002660| 65 20 61 20 6e 61 6d 65 | 22 3b 20 50 45 52 53 4f |e a name|"; PERSO|
|00002670| 4e 24 28 49 29 20 20 20 | 20 20 20 20 20 20 20 27 |N$(I) | '|
|00002680| 4c 4f 41 44 20 54 41 42 | 4c 45 0d 0a 20 20 20 20 |LOAD TAB|LE.. |
|00002690| 20 31 35 30 20 4e 45 58 | 54 20 49 0d 0a 20 20 20 | 150 NEX|T I.. |
|000026a0| 20 20 31 36 30 20 27 0d | 0a 20 20 20 20 20 31 37 | 160 '.|. 17|
|000026b0| 30 20 46 4f 52 20 49 3d | 31 20 54 4f 20 54 4f 54 |0 FOR I=|1 TO TOT|
|000026c0| 2e 52 45 43 0d 0a 20 20 | 20 20 20 31 38 30 20 20 |.REC.. | 180 |
|000026d0| 20 48 4f 4c 44 24 28 49 | 29 20 3d 20 50 45 52 53 | HOLD$(I|) = PERS|
|000026e0| 4f 4e 24 28 49 29 20 20 | 20 20 20 20 20 20 20 20 |ON$(I) | |
|000026f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 27 54 52 41 | | 'TRA|
|00002700| 4e 53 46 45 52 20 54 4f | 20 48 4f 4c 44 20 54 41 |NSFER TO| HOLD TA|
|00002710| 42 4c 45 0d 0a 20 20 20 | 20 20 31 39 30 20 4e 45 |BLE.. | 190 NE|
|00002720| 58 54 20 49 0d 0a 20 20 | 20 20 20 32 30 30 20 27 |XT I.. | 200 '|
|00002730| 0d 0a 20 20 20 20 20 32 | 31 30 20 47 4f 53 55 42 |.. 2|10 GOSUB|
|00002740| 20 35 30 30 30 20 20 20 | 20 20 20 20 20 20 20 20 | 5000 | |
|00002750| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002760| 20 20 20 20 20 20 20 20 | 27 47 4f 20 54 4f 20 53 | |'GO TO S|
|00002770| 4f 52 54 20 52 4f 55 54 | 49 4e 45 0d 0a 20 20 20 |ORT ROUT|INE.. |
|00002780| 20 20 32 32 30 20 27 0d | 0a 20 20 20 20 20 32 33 | 220 '.|. 23|
|00002790| 30 20 46 4f 52 20 49 3d | 20 31 20 54 4f 20 54 4f |0 FOR I=| 1 TO TO|
|000027a0| 54 2e 52 45 43 0d 0a 20 | 20 20 20 20 32 34 30 20 |T.REC.. | 240 |
|000027b0| 20 20 50 52 49 4e 54 20 | 48 4f 4c 44 24 28 49 29 | PRINT |HOLD$(I)|
|000027c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000027d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 27 50 52 | | 'PR|
|000027e0| 49 4e 54 20 53 4f 52 54 | 45 44 20 54 41 42 4c 45 |INT SORT|ED TABLE|
|000027f0| 0d 0a 20 20 20 20 20 32 | 35 30 20 4e 45 58 54 20 |.. 2|50 NEXT |
|00002800| 49 0d 0a 20 20 20 20 20 | 32 36 30 20 27 0d 0a 20 |I.. |260 '.. |
|00002810| 20 20 20 20 32 37 30 20 | 53 54 4f 50 0d 0a 0d 0a | 270 |STOP....|
|00002820| 20 20 20 20 20 46 69 72 | 73 74 20 6c 6f 61 64 20 | Fir|st load |
|00002830| 74 68 65 20 74 61 62 6c | 65 20 76 61 6c 75 65 73 |the tabl|e values|
|00002840| 20 69 6e 74 6f 20 48 4f | 4c 44 24 28 29 20 28 6c | into HO|LD$() (l|
|00002850| 69 6e 65 73 20 31 37 30 | 20 74 68 72 6f 75 67 68 |ines 170| through|
|00002860| 20 31 39 30 29 2e 20 20 | 54 68 65 6e 0d 0a 20 20 | 190). |Then.. |
|00002870| 20 20 20 47 4f 53 55 42 | 20 74 6f 20 79 6f 75 72 | GOSUB| to your|
|00002880| 20 73 6f 72 74 20 72 6f | 75 74 69 6e 65 2e 20 20 | sort ro|utine. |
|00002890| 57 68 65 6e 20 74 68 65 | 20 70 72 6f 67 72 61 6d |When the| program|
|000028a0| 20 72 65 74 75 72 6e 73 | 2c 20 74 68 65 20 63 6f | returns|, the co|
|000028b0| 6e 74 65 6e 74 73 20 6f | 66 0d 0a 20 20 20 20 20 |ntents o|f.. |
|000028c0| 48 4f 4c 44 24 28 29 20 | 77 69 6c 6c 20 68 61 76 |HOLD$() |will hav|
|000028d0| 65 20 62 65 65 6e 20 73 | 6f 72 74 65 64 2e 0d 0a |e been s|orted...|
|000028e0| 0d 0a 0d 0a 20 20 20 20 | 20 1b 45 41 53 43 49 49 |.... | .EASCII|
|000028f0| 20 43 4f 44 45 53 0d 0a | 0d 0a 20 20 20 20 20 1b | CODES..|.. .|
|00002900| 46 48 6f 77 20 64 6f 65 | 73 20 79 6f 75 72 20 50 |FHow doe|s your P|
|00002910| 43 20 6b 6e 6f 77 73 20 | 74 68 61 74 20 41 20 63 |C knows |that A c|
|00002920| 6f 6d 65 73 20 62 65 66 | 6f 72 65 20 42 3f 20 20 |omes bef|ore B? |
|00002930| 53 69 6d 70 6c 65 2e 20 | 20 45 61 63 68 20 63 68 |Simple. | Each ch|
|00002940| 61 72 61 63 74 65 72 0d | 0a 20 20 20 20 20 6f 6e |aracter.|. on|
|00002950| 20 79 6f 75 72 20 6b 65 | 79 62 6f 61 72 64 20 68 | your ke|yboard h|
|00002960| 61 73 20 61 20 6e 75 6d | 65 72 69 63 20 65 71 75 |as a num|eric equ|
|00002970| 69 76 61 6c 65 6e 74 2e | 20 20 49 74 27 73 20 63 |ivalent.| It's c|
|00002980| 61 6c 6c 65 64 20 61 6e | 20 41 53 43 49 49 0d 0a |alled an| ASCII..|
|00002990| 20 20 20 20 20 28 41 6d | 65 72 69 63 61 6e 20 53 | (Am|erican S|
|000029a0| 74 61 6e 64 61 72 64 20 | 43 6f 64 65 20 66 6f 72 |tandard |Code for|
|000029b0| 20 49 6e 66 6f 72 6d 61 | 74 69 6f 6e 20 49 6e 74 | Informa|tion Int|
|000029c0| 65 72 63 68 61 6e 67 65 | 29 20 63 6f 64 65 2e 20 |erchange|) code. |
|000029d0| 20 59 6f 75 72 20 50 43 | 0d 0a 20 20 20 20 20 74 | Your PC|.. t|
|000029e0| 72 61 6e 73 6c 61 74 65 | 73 20 61 6c 6c 20 63 68 |ranslate|s all ch|
|000029f0| 61 72 61 63 74 65 72 73 | 20 74 6f 20 74 68 69 73 |aracters| to this|
|00002a00| 20 63 6f 64 65 20 61 6e | 64 20 63 6f 6d 70 61 72 | code an|d compar|
|00002a10| 65 73 20 74 68 65 69 72 | 20 6e 75 6d 65 72 69 63 |es their| numeric|
|00002a20| 0d 0a 20 20 20 20 20 76 | 61 6c 75 65 73 2e 20 20 |.. v|alues. |
|00002a30| 53 6f 6d 65 20 41 53 43 | 49 49 20 65 71 75 69 76 |Some ASC|II equiv|
|00002a40| 61 6c 65 6e 74 73 20 61 | 72 65 3a 0d 0a 0d 0a 20 |alents a|re:.... |
|00002a50| 20 20 20 20 2d 20 4c 6f | 77 65 72 20 63 61 73 65 | - Lo|wer case|
|00002a60| 20 61 20 74 68 72 6f 75 | 67 68 20 7a 20 61 72 65 | a throu|gh z are|
|00002a70| 20 74 72 61 6e 73 6c 61 | 74 65 64 20 74 6f 20 39 | transla|ted to 9|
|00002a80| 37 20 74 68 72 6f 75 67 | 68 20 31 32 32 20 72 65 |7 throug|h 122 re|
|00002a90| 73 70 65 63 74 69 76 65 | 6c 79 2e 0d 0a 20 20 20 |spective|ly... |
|00002aa0| 20 20 2d 20 55 70 70 65 | 72 20 63 61 73 65 20 41 | - Uppe|r case A|
|00002ab0| 20 74 68 72 6f 75 67 68 | 20 5a 20 61 72 65 20 74 | through| Z are t|
|00002ac0| 72 61 6e 73 6c 61 74 65 | 64 20 74 6f 20 36 35 20 |ranslate|d to 65 |
|00002ad0| 74 68 72 6f 75 67 68 20 | 39 30 20 72 65 73 70 65 |through |90 respe|
|00002ae0| 63 74 69 76 65 6c 79 2e | 0d 0a 20 20 20 20 20 2d |ctively.|.. -|
|00002af0| 20 54 68 65 20 6e 75 6d | 62 65 72 73 20 30 20 74 | The num|bers 0 t|
|00002b00| 68 72 6f 75 67 68 20 39 | 20 61 72 65 20 74 72 61 |hrough 9| are tra|
|00002b10| 6e 73 6c 61 74 65 64 20 | 74 6f 20 34 38 20 74 68 |nslated |to 48 th|
|00002b20| 72 6f 75 67 68 20 35 37 | 20 72 65 73 70 65 63 74 |rough 57| respect|
|00002b30| 69 76 65 6c 79 2e 0d 0a | 0d 0a 20 20 20 20 20 41 |ively...|.. A|
|00002b40| 20 73 74 72 69 6e 67 20 | 73 6f 72 74 20 63 6f 6d | string |sort com|
|00002b50| 70 61 72 65 73 20 74 68 | 65 20 41 53 43 49 49 20 |pares th|e ASCII |
|00002b60| 76 61 6c 75 65 20 6f 66 | 20 74 68 65 20 66 69 72 |value of| the fir|
|00002b70| 73 74 20 63 68 61 72 61 | 63 74 65 72 20 6f 66 20 |st chara|cter of |
|00002b80| 61 6e 20 69 74 65 6d 0d | 0a 20 20 20 20 20 77 69 |an item.|. wi|
|00002b90| 74 68 20 74 68 65 20 41 | 53 43 49 49 20 76 61 6c |th the A|SCII val|
|00002ba0| 75 65 20 6f 66 20 74 68 | 65 20 66 69 72 73 74 20 |ue of th|e first |
|00002bb0| 63 68 61 72 61 63 74 65 | 72 20 6f 66 20 74 68 65 |characte|r of the|
|00002bc0| 20 73 65 63 6f 6e 64 20 | 69 74 65 6d 2e 20 20 49 | second |item. I|
|00002bd0| 66 20 74 68 65 0d 0a 20 | 20 20 20 20 66 69 72 73 |f the.. | firs|
|00002be0| 74 20 74 77 6f 20 61 72 | 65 20 65 71 75 61 6c 2c |t two ar|e equal,|
|00002bf0| 20 69 74 20 6c 6f 6f 6b | 73 20 61 74 20 74 68 65 | it look|s at the|
|00002c00| 20 73 65 63 6f 6e 64 20 | 63 68 61 72 61 63 74 65 | second |characte|
|00002c10| 72 2c 20 65 74 63 2e 20 | 20 54 68 61 74 27 73 20 |r, etc. | That's |
|00002c20| 77 68 79 0d 0a 20 20 20 | 20 20 77 65 20 63 61 75 |why.. | we cau|
|00002c30| 74 69 6f 6e 65 64 20 79 | 6f 75 20 61 67 61 69 6e |tioned y|ou again|
|00002c40| 73 74 20 75 73 69 6e 67 | 20 61 20 73 74 72 69 6e |st using| a strin|
|00002c50| 67 20 73 6f 72 74 20 66 | 6f 72 20 6e 75 6d 62 65 |g sort f|or numbe|
|00002c60| 72 73 2e 20 20 4c 6f 6f | 6b 20 61 74 20 74 68 65 |rs. Loo|k at the|
|00002c70| 0d 0a 20 20 20 20 20 66 | 6f 6c 6c 6f 77 69 6e 67 |.. f|ollowing|
|00002c80| 20 73 65 71 75 65 6e 63 | 65 3a 0d 0a 0d 0a 20 20 | sequenc|e:.... |
|00002c90| 20 20 20 20 20 20 31 2c | 20 31 31 2c 20 31 30 31 | 1,| 11, 101|
|00002ca0| 0d 0a 0d 0a 20 20 20 20 | 20 54 68 65 20 61 6c 70 |.... | The alp|
|00002cb0| 68 61 20 73 6f 72 74 20 | 63 6f 6d 70 61 72 65 73 |ha sort |compares|
|00002cc0| 20 41 53 43 49 49 20 63 | 6f 64 65 73 20 72 61 74 | ASCII c|odes rat|
|00002cd0| 68 65 72 20 74 68 61 6e | 20 74 6f 74 61 6c 20 76 |her than| total v|
|00002ce0| 61 6c 75 65 73 2e 20 20 | 53 69 6e 63 65 20 74 68 |alues. |Since th|
|00002cf0| 65 0d 0a 20 20 20 20 20 | 30 20 69 6e 20 31 30 31 |e.. |0 in 101|
|00002d00| 20 69 73 20 6c 6f 77 65 | 72 20 74 68 61 6e 20 74 | is lowe|r than t|
|00002d10| 68 65 20 73 65 63 6f 6e | 64 20 31 20 69 6e 20 31 |he secon|d 1 in 1|
|00002d20| 31 2c 20 69 74 20 72 65 | 6f 72 64 65 72 73 20 74 |1, it re|orders t|
|00002d30| 68 65 20 73 65 71 75 65 | 6e 63 65 20 61 73 3a 0d |he seque|nce as:.|
|00002d40| 0a 0d 0a 20 20 20 20 20 | 20 20 20 31 2c 20 31 30 |... | 1, 10|
|00002d50| 31 2c 20 31 31 0d 0a 0d | 0a 0d 0a 0d 0a 0d 0a 0d |1, 11...|........|
|00002d60| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | |
|00002d70| 20 20 1b 45 20 20 20 20 | 20 20 20 20 20 20 20 20 | .E | |
|00002d80| 20 20 20 20 1b 46 20 20 | 20 20 20 20 20 1b 45 20 | .F | .E |
|00002d90| 31 30 30 0d 0a 0d 0a 0c | 0d 0a 0d 0a 0d 0a 0d 0a |100.....|........|
|00002da0| 1b 46 20 20 20 20 20 1b | 45 43 48 41 50 54 45 52 |.F .|ECHAPTER|
|00002db0| 20 38 1b 46 20 20 20 20 | 20 20 20 20 20 20 20 20 | 8.F | |
|00002dc0| 20 20 20 20 20 1b 45 53 | 4f 52 54 49 4e 47 20 49 | .ES|ORTING I|
|00002dd0| 54 20 41 4c 4c 20 4f 55 | 54 20 20 1b 46 20 20 20 |T ALL OU|T .F |
|00002de0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 1b 45 | | .E|
|00002df0| 43 48 41 50 54 45 52 20 | 38 0d 0a 0d 0a 0d 0a 20 |CHAPTER |8...... |
|00002e00| 20 20 20 20 53 4f 52 54 | 49 4e 47 20 4d 55 4c 54 | SORT|ING MULT|
|00002e10| 49 50 4c 45 20 54 41 42 | 4c 45 53 0d 0a 0d 0a 20 |IPLE TAB|LES.... |
|00002e20| 20 20 20 20 1b 46 53 75 | 70 70 6f 73 65 20 74 68 | .FSu|ppose th|
|00002e30| 61 74 20 79 6f 75 20 61 | 72 65 20 77 6f 72 6b 69 |at you a|re worki|
|00002e40| 6e 67 20 77 69 74 68 20 | 61 20 66 6c 69 67 68 74 |ng with |a flight|
|00002e50| 20 70 72 6f 67 72 61 6d | 20 74 68 61 74 20 68 61 | program| that ha|
|00002e60| 73 20 74 68 65 0d 0a 20 | 20 20 20 20 66 6f 6c 6c |s the.. | foll|
|00002e70| 6f 77 69 6e 67 20 73 65 | 74 20 6f 66 20 74 61 62 |owing se|t of tab|
|00002e80| 6c 65 73 20 61 73 73 6f | 63 69 61 74 65 64 20 77 |les asso|ciated w|
|00002e90| 69 74 68 20 69 74 3a 0d | 0a 0d 0a 0d 0a 20 20 20 |ith it:.|..... |
|00002ea0| 20 20 20 20 46 6c 69 67 | 68 74 20 20 20 20 20 20 | Flig|ht |
|00002eb0| 20 44 65 73 74 69 6e 61 | 74 69 6f 6e 20 20 20 20 | Destina|tion |
|00002ec0| 20 20 20 20 44 65 70 61 | 72 74 75 72 65 20 20 20 | Depa|rture |
|00002ed0| 20 20 20 20 20 20 20 41 | 72 72 69 76 61 6c 0d 0a | A|rrival..|
|00002ee0| 0d 0a 20 20 20 20 20 20 | 20 20 32 30 34 42 20 20 |.. | 204B |
|00002ef0| 20 20 20 20 20 20 20 4e | 65 77 20 59 6f 72 6b 20 | N|ew York |
|00002f00| 20 20 20 20 20 20 20 20 | 20 20 31 31 3a 35 30 20 | | 11:50 |
|00002f10| 41 4d 20 20 20 20 20 20 | 20 20 20 20 31 3a 30 33 |AM | 1:03|
|00002f20| 20 50 4d 0d 0a 20 20 20 | 20 20 20 20 20 20 31 37 | PM.. | 17|
|00002f30| 20 20 20 20 20 20 20 20 | 20 20 54 65 6e 6e 65 73 | | Tennes|
|00002f40| 73 65 65 20 20 20 20 20 | 20 20 20 20 20 20 37 3a |see | 7:|
|00002f50| 31 32 20 50 4d 20 20 20 | 20 20 20 20 20 20 31 30 |12 PM | 10|
|00002f60| 3a 31 32 20 50 4d 0d 0a | 20 20 20 20 20 20 20 20 |:12 PM..| |
|00002f70| 31 31 31 20 20 20 20 20 | 20 20 20 20 20 43 68 69 |111 | Chi|
|00002f80| 63 61 67 6f 20 20 20 20 | 20 20 20 20 20 20 20 20 |cago | |
|00002f90| 20 33 3a 31 35 20 50 4d | 20 20 20 20 20 20 20 20 | 3:15 PM| |
|00002fa0| 20 20 35 3a 31 37 20 50 | 4d 0d 0a 20 20 20 20 20 | 5:17 P|M.. |
|00002fb0| 20 20 20 33 34 35 43 20 | 20 20 20 20 20 20 20 20 | 345C | |
|00002fc0| 4f 73 68 6b 6f 73 68 20 | 20 20 20 20 20 20 20 20 |Oshkosh | |
|00002fd0| 20 20 20 31 30 3a 30 30 | 20 41 4d 20 20 20 20 20 | 10:00| AM |
|00002fe0| 20 20 20 20 20 32 3a 34 | 33 20 50 4d 0d 0a 0d 0a | 2:4|3 PM....|
|00002ff0| 20 20 20 20 20 57 68 61 | 74 20 68 61 70 70 65 6e | Wha|t happen|
|00003000| 73 20 69 66 20 79 6f 75 | 20 73 6f 72 74 20 6f 6e |s if you| sort on|
|00003010| 20 66 6c 69 67 68 74 20 | 6e 75 6d 62 65 72 20 61 | flight |number a|
|00003020| 6e 64 20 74 68 65 6e 20 | 70 72 69 6e 74 20 61 6c |nd then |print al|
|00003030| 6c 20 74 68 65 20 6c 69 | 73 74 73 3f 0d 0a 20 20 |l the li|sts?.. |
|00003040| 20 20 20 59 6f 75 20 67 | 6f 74 20 69 74 2c 20 74 | You g|ot it, t|
|00003050| 68 65 20 64 65 73 74 69 | 6e 61 74 69 6f 6e 2c 20 |he desti|nation, |
|00003060| 64 65 70 61 72 74 75 72 | 65 20 61 6e 64 20 61 72 |departur|e and ar|
|00003070| 72 69 76 61 6c 20 77 69 | 6c 6c 20 62 65 20 6f 75 |rival wi|ll be ou|
|00003080| 74 20 6f 66 20 6f 72 64 | 65 72 2e 0d 0a 20 20 20 |t of ord|er... |
|00003090| 20 20 4d 6f 73 74 20 6f | 66 20 74 68 65 20 74 69 | Most o|f the ti|
|000030a0| 6d 65 2c 20 79 6f 75 20 | 77 69 6c 6c 20 62 65 20 |me, you |will be |
|000030b0| 64 65 61 6c 69 6e 67 20 | 77 69 74 68 20 6d 75 6c |dealing |with mul|
|000030c0| 74 69 70 6c 65 20 74 61 | 62 6c 65 73 2e 20 20 48 |tiple ta|bles. H|
|000030d0| 65 6e 63 65 20 79 6f 75 | 0d 0a 20 20 20 20 20 6e |ence you|.. n|
|000030e0| 65 65 64 20 74 68 65 20 | 61 62 69 6c 69 74 79 20 |eed the |ability |
|000030f0| 74 6f 20 73 6f 72 74 20 | 61 20 74 61 62 6c 65 20 |to sort |a table |
|00003100| 61 6e 64 20 6b 65 65 70 | 20 74 68 65 20 69 6e 66 |and keep| the inf|
|00003110| 6f 72 6d 61 74 69 6f 6e | 20 69 6e 20 74 68 65 20 |ormation| in the |
|00003120| 6f 74 68 65 72 0d 0a 20 | 20 20 20 20 74 61 62 6c |other.. | tabl|
|00003130| 65 73 20 70 61 72 61 6c | 6c 65 6c 2e 20 20 4c 65 |es paral|lel. Le|
|00003140| 74 27 73 20 61 64 64 20 | 61 20 63 6f 6c 75 6d 6e |t's add |a column|
|00003150| 20 6f 66 20 6f 72 69 67 | 69 6e 61 6c 20 6c 6f 63 | of orig|inal loc|
|00003160| 61 74 69 6f 6e 73 20 28 | 4f 52 49 47 28 29 29 3a |ations (|ORIG()):|
|00003170| 0d 0a 0d 0a 20 20 20 20 | 20 20 4f 52 49 47 28 29 |.... | ORIG()|
|00003180| 20 20 20 20 20 20 20 20 | 46 4c 49 47 48 54 24 28 | |FLIGHT$(|
|00003190| 29 20 20 20 20 20 20 20 | 20 20 44 45 53 54 24 28 |) | DEST$(|
|000031a0| 29 20 20 20 20 20 20 20 | 20 20 20 44 45 50 54 24 |) | DEPT$|
|000031b0| 28 29 1b 45 20 20 20 20 | 20 20 1b 46 20 41 52 52 |().E | .F ARR|
|000031c0| 49 56 24 28 29 0d 0a 0d | 0a 20 20 20 20 20 20 20 |IV$()...|. |
|000031d0| 20 20 31 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | 1 | |
|000031e0| 32 30 34 42 20 20 20 20 | 20 20 20 20 20 20 20 4e |204B | N|
|000031f0| 65 77 20 59 6f 72 6b 20 | 20 20 20 20 20 20 20 20 |ew York | |
|00003200| 31 31 3a 35 30 20 41 4d | 20 20 20 20 20 20 20 31 |11:50 AM| 1|
|00003210| 3a 30 33 20 50 4d 0d 0a | 20 20 20 20 20 20 20 20 |:03 PM..| |
|00003220| 20 32 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | 2 | |
|00003230| 31 37 20 20 20 20 20 20 | 20 20 20 20 20 54 65 6e |17 | Ten|
|00003240| 6e 65 73 73 65 65 20 20 | 20 20 20 20 20 20 20 20 |nessee | |
|00003250| 37 3a 31 32 20 50 4d 20 | 20 20 20 20 20 31 30 3a |7:12 PM | 10:|
|00003260| 31 32 20 50 4d 0d 0a 20 | 20 20 20 20 20 20 20 20 |12 PM.. | |
|00003270| 33 20 20 20 20 20 20 20 | 20 20 20 20 20 20 31 39 |3 | 19|
|00003280| 31 20 20 20 20 20 20 20 | 20 20 20 20 20 20 43 68 |1 | Ch|
|00003290| 69 63 61 67 6f 20 20 20 | 20 20 20 20 20 20 20 33 |icago | 3|
|000032a0| 3a 31 35 20 50 4d 20 20 | 20 20 20 20 20 35 3a 31 |:15 PM | 5:1|
|000032b0| 37 20 50 4d 0d 0a 20 20 | 20 20 20 20 20 20 20 34 |7 PM.. | 4|
|000032c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 33 34 35 | | 345|
|000032d0| 43 20 20 20 20 20 20 20 | 20 20 20 20 20 4f 73 68 |C | Osh|
|000032e0| 6b 6f 73 68 20 20 20 20 | 20 20 20 20 20 31 30 3a |kosh | 10:|
|000032f0| 30 30 20 41 4d 20 20 20 | 20 20 1b 45 20 1b 46 20 |00 AM | .E .F |
|00003300| 32 3a 34 33 20 50 4d 0d | 0a 0d 0a 20 20 20 20 20 |2:43 PM.|... |
|00003310| 4e 65 78 74 2c 20 77 65 | 20 70 75 74 20 66 6c 69 |Next, we| put fli|
|00003320| 67 68 74 20 6e 75 6d 62 | 65 72 73 20 69 6e 20 74 |ght numb|ers in t|
|00003330| 68 65 20 74 61 62 6c 65 | 20 48 4f 4c 44 24 28 29 |he table| HOLD$()|
|00003340| 2c 20 73 6f 72 74 20 74 | 68 65 6d 2c 20 61 6e 64 |, sort t|hem, and|
|00003350| 20 6b 65 65 70 0d 0a 20 | 20 20 20 20 74 68 65 20 | keep.. | the |
|00003360| 74 61 62 6c 65 20 6c 6f | 63 61 74 69 6f 6e 73 2c |table lo|cations,|
|00003370| 20 4f 52 49 47 28 29 2c | 20 70 61 72 61 6c 6c 65 | ORIG(),| paralle|
|00003380| 6c 20 61 73 20 77 65 20 | 67 6f 3a 0d 0a 0d 0a 20 |l as we |go:.... |
|00003390| 20 20 20 20 20 20 4f 52 | 49 47 28 29 20 20 20 20 | OR|IG() |
|000033a0| 20 48 4f 4c 44 24 28 29 | 20 20 46 4c 49 47 48 54 | HOLD$()| FLIGHT|
|000033b0| 24 28 29 20 20 20 20 20 | 20 20 44 45 53 54 24 28 |$() | DEST$(|
|000033c0| 29 20 20 20 20 20 20 20 | 20 44 45 50 54 24 28 29 |) | DEPT$()|
|000033d0| 1b 45 20 20 20 1b 46 20 | 41 52 52 49 56 24 28 29 |.E .F |ARRIV$()|
|000033e0| 0d 0a 0d 0a 20 20 20 20 | 20 20 20 20 20 32 20 20 |.... | 2 |
|000033f0| 20 20 20 20 20 20 20 20 | 31 37 20 20 20 20 20 20 | |17 |
|00003400| 20 32 30 34 42 20 20 20 | 20 20 20 20 20 20 4e 65 | 204B | Ne|
|00003410| 77 20 59 6f 72 6b 20 20 | 20 20 20 20 20 31 31 3a |w York | 11:|
|00003420| 35 30 20 41 4d 20 20 20 | 20 20 31 3a 30 33 20 50 |50 AM | 1:03 P|
|00003430| 4d 0d 0a 20 20 20 20 20 | 20 20 20 20 33 20 20 20 |M.. | 3 |
|00003440| 20 20 20 20 20 20 31 39 | 31 20 20 20 20 20 20 20 | 19|1 |
|00003450| 20 31 37 20 20 20 20 20 | 20 20 20 20 54 65 6e 6e | 17 | Tenn|
|00003460| 65 73 73 65 65 20 20 20 | 20 20 20 20 20 37 3a 31 |essee | 7:1|
|00003470| 32 20 50 4d 20 20 20 20 | 31 30 3a 31 32 20 50 4d |2 PM |10:12 PM|
|00003480| 0d 0a 20 20 20 20 20 20 | 20 20 20 31 20 20 20 20 |.. | 1 |
|00003490| 20 20 20 20 20 32 30 34 | 42 20 20 20 20 20 20 31 | 204|B 1|
|000034a0| 39 31 20 20 20 20 20 20 | 20 20 20 20 20 43 68 69 |91 | Chi|
|000034b0| 63 61 67 6f 20 20 20 20 | 20 20 20 20 33 3a 31 35 |cago | 3:15|
|000034c0| 20 50 4d 20 20 20 20 20 | 35 3a 31 37 20 50 4d 0d | PM |5:17 PM.|
|000034d0| 0a 20 20 20 20 20 20 20 | 20 20 34 20 20 20 20 20 |. | 4 |
|000034e0| 20 20 20 20 33 34 35 43 | 20 20 20 20 20 20 33 34 | 345C| 34|
|000034f0| 35 43 20 20 20 20 20 20 | 20 20 20 20 4f 73 68 6b |5C | Oshk|
|00003500| 6f 73 68 20 20 20 20 20 | 20 20 31 30 3a 30 30 20 |osh | 10:00 |
|00003510| 41 4d 20 20 20 20 20 32 | 3a 34 33 20 50 4d 0d 0a |AM 2|:43 PM..|
|00003520| 0d 0a 20 20 20 20 20 48 | 4f 4c 44 24 28 29 20 68 |.. H|OLD$() h|
|00003530| 6f 6c 64 73 20 74 68 65 | 20 73 6f 72 74 65 64 20 |olds the| sorted |
|00003540| 66 6c 69 67 68 74 20 6e | 75 6d 62 65 72 73 2e 20 |flight n|umbers. |
|00003550| 20 54 68 65 20 6f 72 69 | 67 69 6e 61 6c 20 74 61 | The ori|ginal ta|
|00003560| 62 6c 65 2c 20 46 4c 49 | 47 48 54 24 28 29 2c 0d |ble, FLI|GHT$(),.|
|00003570| 0a 20 20 20 20 20 72 65 | 6d 61 69 6e 73 20 74 68 |. re|mains th|
|00003580| 65 20 73 61 6d 65 2e 0d | 0a 0d 0a 20 20 20 20 20 |e same..|... |
|00003590| 4c 6f 6f 6b 20 61 74 20 | 77 68 61 74 20 68 61 70 |Look at |what hap|
|000035a0| 70 65 6e 65 64 20 74 6f | 20 4f 52 49 47 28 29 2e |pened to| ORIG().|
|000035b0| 20 20 45 6e 74 72 79 20 | 31 20 69 73 20 32 2c 20 | Entry |1 is 2, |
|000035c0| 74 68 65 20 6c 6f 63 61 | 74 69 6f 6e 20 69 6e 0d |the loca|tion in.|
|000035d0| 0a 20 20 20 20 20 46 4c | 49 47 48 54 24 28 29 20 |. FL|IGHT$() |
|000035e0| 74 68 61 74 20 73 68 6f | 75 6c 64 20 62 65 20 70 |that sho|uld be p|
|000035f0| 72 69 6e 74 65 64 20 66 | 69 72 73 74 2e 20 20 45 |rinted f|irst. E|
|00003600| 6e 74 72 79 20 32 20 69 | 73 20 33 2c 20 74 68 65 |ntry 2 i|s 3, the|
|00003610| 20 6c 6f 63 61 74 69 6f | 6e 20 74 68 61 74 0d 0a | locatio|n that..|
|00003620| 20 20 20 20 20 73 68 6f | 75 6c 64 20 62 65 20 70 | sho|uld be p|
|00003630| 72 69 6e 74 65 64 20 73 | 65 63 6f 6e 64 2e 20 20 |rinted s|econd. |
|00003640| 45 6e 74 72 79 20 33 20 | 69 73 20 31 2c 20 74 68 |Entry 3 |is 1, th|
|00003650| 65 20 6c 6f 63 61 74 69 | 6f 6e 20 74 68 61 74 20 |e locati|on that |
|00003660| 63 6f 6d 65 73 20 74 68 | 69 72 64 2c 0d 0a 20 20 |comes th|ird,.. |
|00003670| 20 20 20 65 74 63 2e 2e | 2e 2e 20 20 4f 52 49 47 | etc..|.. ORIG|
|00003680| 28 29 20 73 74 6f 72 65 | 73 20 74 68 65 20 6f 72 |() store|s the or|
|00003690| 69 67 69 6e 61 6c 20 6c | 6f 63 61 74 69 6f 6e 73 |iginal l|ocations|
|000036a0| 2c 20 68 6f 77 65 76 65 | 72 20 69 74 20 69 73 20 |, howeve|r it is |
|000036b0| 73 6f 72 74 65 64 2e 20 | 20 49 74 0d 0a 20 20 20 |sorted. | It.. |
|000036c0| 20 20 70 6f 69 6e 74 73 | 20 74 6f 20 77 68 61 74 | points| to what|
|000036d0| 20 73 68 6f 75 6c 64 20 | 62 65 20 70 72 69 6e 74 | should |be print|
|000036e0| 65 64 2e 20 20 57 65 20 | 63 61 6e 20 75 73 65 20 |ed. We |can use |
|000036f0| 74 68 69 73 20 74 6f 20 | 70 72 69 6e 74 20 61 20 |this to |print a |
|00003700| 73 6f 72 74 65 64 0d 0a | 20 20 20 20 20 6c 69 73 |sorted..| lis|
|00003710| 74 20 6f 66 20 66 6c 69 | 67 68 74 73 20 61 6e 64 |t of fli|ghts and|
|00003720| 20 64 65 73 74 69 6e 61 | 74 69 6f 6e 73 20 75 73 | destina|tions us|
|00003730| 69 6e 67 20 74 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |ing the |followin|
|00003740| 67 20 74 65 63 68 6e 69 | 71 75 65 3a 0d 0a 0d 0a |g techni|que:....|
|00003750| 20 20 20 20 20 32 30 30 | 20 46 4f 52 20 49 20 3d | 200| FOR I =|
|00003760| 20 31 20 54 4f 20 54 4f | 54 2e 52 45 43 0d 0a 20 | 1 TO TO|T.REC.. |
|00003770| 20 20 20 20 32 31 30 20 | 20 20 4c 20 3d 20 4f 52 | 210 | L = OR|
|00003780| 49 47 28 49 29 20 20 20 | 1b 45 20 1b 46 20 20 20 |IG(I) |.E .F |
|00003790| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000037a0| 20 20 27 54 52 41 4e 53 | 4c 41 54 45 20 54 4f 20 | 'TRANS|LATE TO |
|000037b0| 44 45 53 49 52 45 44 20 | 4c 4f 43 41 54 49 4f 4e |DESIRED |LOCATION|
|000037c0| 0d 0a 20 20 20 20 20 32 | 32 30 20 20 20 50 52 49 |.. 2|20 PRI|
|000037d0| 4e 54 20 46 4c 49 47 48 | 54 24 28 4c 29 2c 20 44 |NT FLIGH|T$(L), D|
|000037e0| 45 53 54 24 28 4c 29 0d | 0a 20 20 20 20 20 32 33 |EST$(L).|. 23|
|000037f0| 30 20 4e 45 58 54 20 49 | 0d 0a 0d 0a 0d 0a 0d 0a |0 NEXT I|........|
|00003800| 0d 0a 0d 0a 20 20 20 20 | 20 20 20 20 20 20 20 20 |.... | |
|00003810| 20 20 20 20 20 1b 45 20 | 20 20 20 20 20 20 20 20 | .E | |
|00003820| 20 20 20 20 20 20 20 1b | 46 20 20 20 20 20 20 20 | .|F |
|00003830| 1b 45 20 31 30 31 0d 0a | 0d 0a 0c 0d 0a 0d 0a 0d |.E 101..|........|
|00003840| 0a 0d 0a 1b 46 20 20 20 | 20 20 1b 45 43 48 41 50 |....F | .ECHAP|
|00003850| 54 45 52 20 38 1b 46 20 | 20 20 20 20 20 20 20 20 |TER 8.F | |
|00003860| 20 20 20 20 20 20 20 20 | 1b 45 53 4f 52 54 49 4e | |.ESORTIN|
|00003870| 47 20 49 54 20 41 4c 4c | 20 4f 55 54 20 20 1b 46 |G IT ALL| OUT .F|
|00003880| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003890| 20 1b 45 43 48 41 50 54 | 45 52 20 38 0d 0a 0d 0a | .ECHAPT|ER 8....|
|000038a0| 0d 0a 20 20 20 20 20 1b | 46 52 65 76 69 65 77 20 |.. .|FReview |
|000038b0| 74 68 65 20 70 72 65 76 | 69 6f 75 73 20 70 61 67 |the prev|ious pag|
|000038c0| 65 20 61 20 63 6f 75 70 | 6c 65 20 74 6f 20 74 69 |e a coup|le to ti|
|000038d0| 6d 65 73 20 61 6e 64 20 | 67 65 74 20 63 6f 6d 66 |mes and |get comf|
|000038e0| 6f 72 74 61 62 6c 65 20 | 77 69 74 68 20 74 68 65 |ortable |with the|
|000038f0| 0d 0a 20 20 20 20 20 63 | 6f 6e 63 65 70 74 2e 20 |.. c|oncept. |
|00003900| 20 49 6e 20 61 20 6e 75 | 74 73 68 65 6c 6c 2c 20 | In a nu|tshell, |
|00003910| 69 66 20 77 65 20 73 6f | 72 74 20 61 20 74 61 62 |if we so|rt a tab|
|00003920| 6c 65 20 61 6e 64 20 6b | 65 65 70 20 74 72 61 63 |le and k|eep trac|
|00003930| 6b 20 6f 66 20 74 68 65 | 0d 0a 20 20 20 20 20 6f |k of the|.. o|
|00003940| 72 69 67 69 6e 61 6c 20 | 6c 6f 63 61 74 69 6f 6e |riginal |location|
|00003950| 20 6f 66 20 74 68 65 20 | 65 6e 74 72 69 65 73 20 | of the |entries |
|00003960| 69 6e 20 4f 52 49 47 28 | 29 2c 20 77 65 20 63 61 |in ORIG(|), we ca|
|00003970| 6e 20 75 73 65 20 4f 52 | 49 47 28 29 20 61 73 20 |n use OR|IG() as |
|00003980| 61 0d 0a 20 20 20 20 20 | 70 6f 69 6e 74 65 72 2e |a.. |pointer.|
|00003990| 20 20 54 68 65 20 6f 72 | 69 67 69 6e 61 6c 20 74 | The or|iginal t|
|000039a0| 61 62 6c 65 73 2c 20 79 | 6f 75 20 73 65 65 2c 20 |ables, y|ou see, |
|000039b0| 61 72 65 20 6e 65 76 65 | 72 20 72 65 73 65 71 75 |are neve|r resequ|
|000039c0| 65 6e 63 65 64 2e 0d 0a | 0d 0a 20 20 20 20 20 41 |enced...|.. A|
|000039d0| 20 73 75 62 72 6f 75 74 | 69 6e 65 20 74 68 61 74 | subrout|ine that|
|000039e0| 20 70 65 72 66 6f 72 6d | 73 20 74 68 65 20 73 6f | perform|s the so|
|000039f0| 72 74 20 69 73 20 63 6f | 64 65 64 20 62 65 6c 6f |rt is co|ded belo|
|00003a00| 77 3a 0d 0a 0d 0a 0d 0a | 20 20 20 20 20 35 30 30 |w:......| 500|
|00003a10| 30 20 27 20 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |0 ' ****|********|
|00003a20| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00003a30| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00003a40| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00003a50| 2a 2a 2a 0d 0a 20 20 20 | 20 20 35 30 31 30 20 27 |***.. | 5010 '|
|00003a60| 20 54 48 49 53 20 52 4f | 55 54 49 4e 45 20 53 4f | THIS RO|UTINE SO|
|00003a70| 52 54 53 20 41 20 54 41 | 42 4c 45 20 49 4e 20 49 |RTS A TA|BLE IN I|
|00003a80| 4e 43 52 45 41 53 49 4e | 47 20 4f 52 44 45 52 2e |NCREASIN|G ORDER.|
|00003a90| 20 20 50 41 52 41 4d 45 | 54 45 52 53 20 41 52 45 | PARAME|TERS ARE|
|00003aa0| 0d 0a 20 20 20 20 20 35 | 30 32 30 20 27 20 41 53 |.. 5|020 ' AS|
|00003ab0| 20 46 4f 4c 4c 4f 57 53 | 3a 20 20 45 58 50 45 43 | FOLLOWS|: EXPEC|
|00003ac0| 54 53 20 48 4f 4c 44 24 | 28 29 2c 20 54 48 45 20 |TS HOLD$|(), THE |
|00003ad0| 54 41 42 4c 45 20 54 4f | 20 42 45 20 53 4f 52 54 |TABLE TO| BE SORT|
|00003ae0| 45 44 20 41 4e 44 20 54 | 4f 54 2e 52 45 43 0d 0a |ED AND T|OT.REC..|
|00003af0| 20 20 20 20 20 35 30 33 | 30 20 27 20 54 48 45 20 | 503|0 ' THE |
|00003b00| 23 20 4f 46 20 45 4e 54 | 52 49 45 53 20 49 4e 20 |# OF ENT|RIES IN |
|00003b10| 49 54 2e 20 20 52 45 54 | 55 52 4e 53 20 4f 52 49 |IT. RET|URNS ORI|
|00003b20| 47 28 29 2c 20 54 48 45 | 20 4f 52 49 47 49 4e 41 |G(), THE| ORIGINA|
|00003b30| 4c 20 4c 4f 43 41 54 49 | 4f 4e 53 0d 0a 20 20 20 |L LOCATI|ONS.. |
|00003b40| 20 20 35 30 35 30 20 27 | 20 2a 2a 2a 2a 2a 2a 2a | 5050 '| *******|
|00003b50| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00003b60| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00003b70| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00003b80| 2a 2a 2a 2a 2a 2a 2a 2a | 0d 0a 20 20 20 20 20 35 |********|.. 5|
|00003b90| 30 36 30 20 27 0d 0a 20 | 20 20 20 20 35 30 37 30 |060 '.. | 5070|
|00003ba0| 20 46 4f 52 20 49 20 3d | 20 31 20 54 4f 20 54 4f | FOR I =| 1 TO TO|
|00003bb0| 54 2e 52 45 43 0d 0a 20 | 20 20 20 20 35 30 38 30 |T.REC.. | 5080|
|00003bc0| 20 20 20 4f 52 49 47 28 | 49 29 20 3d 20 49 20 20 | ORIG(|I) = I |
|00003bd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003be0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 27 53 54 | | 'ST|
|00003bf0| 4f 52 45 20 4f 52 49 47 | 20 4c 4f 43 41 54 49 4f |ORE ORIG| LOCATIO|
|00003c00| 4e 53 0d 0a 20 20 20 20 | 20 35 30 39 30 20 4e 45 |NS.. | 5090 NE|
|00003c10| 58 54 20 49 0d 0a 20 20 | 20 20 20 35 31 30 30 20 |XT I.. | 5100 |
|00003c20| 27 0d 0a 20 20 20 20 20 | 35 31 31 30 20 53 57 2e |'.. |5110 SW.|
|00003c30| 46 4c 47 20 3d 20 31 20 | 20 20 20 20 20 20 20 20 |FLG = 1 | |
|00003c40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003c50| 20 20 20 20 20 20 20 20 | 20 27 53 45 54 20 46 4c | | 'SET FL|
|00003c60| 41 47 20 54 4f 20 4e 4f | 20 53 57 41 50 0d 0a 20 |AG TO NO| SWAP.. |
|00003c70| 20 20 20 20 35 31 32 30 | 20 4c 41 53 54 20 20 20 | 5120| LAST |
|00003c80| 3d 20 54 4f 54 2e 52 45 | 43 20 2d 20 31 20 20 20 |= TOT.RE|C - 1 |
|00003c90| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003ca0| 20 20 20 20 20 27 45 4e | 44 20 4f 46 20 46 49 52 | 'EN|D OF FIR|
|00003cb0| 53 54 20 50 41 53 53 0d | 0a 20 20 20 20 20 35 31 |ST PASS.|. 51|
|00003cc0| 33 30 20 27 0d 0a 20 20 | 20 20 20 35 31 34 30 20 |30 '.. | 5140 |
|00003cd0| 57 48 49 4c 45 20 4c 41 | 53 54 20 3c 3e 20 30 20 |WHILE LA|ST <> 0 |
|00003ce0| 20 41 4e 44 20 20 53 57 | 2e 46 4c 47 20 3c 3e 20 | AND SW|.FLG <> |
|00003cf0| 30 20 20 20 20 20 20 20 | 20 20 20 20 27 53 54 41 |0 | 'STA|
|00003d00| 52 54 20 53 4f 52 54 0d | 0a 20 20 20 20 20 35 31 |RT SORT.|. 51|
|00003d10| 35 30 20 27 0d 0a 20 20 | 20 20 20 35 31 36 30 20 |50 '.. | 5160 |
|00003d20| 20 20 20 53 57 2e 46 4c | 47 20 3d 20 30 20 20 20 | SW.FL|G = 0 |
|00003d30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003d40| 20 20 20 20 20 20 20 20 | 20 20 20 20 27 52 45 53 | | 'RES|
|00003d50| 45 54 20 50 52 45 56 49 | 4f 55 53 20 50 41 53 53 |ET PREVI|OUS PASS|
|00003d60| 0d 0a 20 20 20 20 20 35 | 31 37 30 20 27 0d 0a 20 |.. 5|170 '.. |
|00003d70| 20 20 20 20 35 31 38 30 | 20 20 20 20 46 4f 52 20 | 5180| FOR |
|00003d80| 4b 20 3d 20 31 20 54 4f | 20 4c 41 53 54 20 20 20 |K = 1 TO| LAST |
|00003d90| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003da0| 20 20 20 20 20 27 44 4f | 20 4f 4e 45 20 50 41 53 | 'DO| ONE PAS|
|00003db0| 53 0d 0a 20 20 20 20 20 | 35 31 39 30 20 20 20 20 |S.. |5190 |
|00003dc0| 20 20 49 46 20 48 4f 4c | 44 24 28 4b 29 20 3e 20 | IF HOL|D$(K) > |
|00003dd0| 48 4f 4c 44 24 28 4b 2b | 31 29 20 54 48 45 4e 20 |HOLD$(K+|1) THEN |
|00003de0| 53 57 2e 46 4c 47 20 3d | 20 31 3a 0d 0a 20 20 20 |SW.FLG =| 1:.. |
|00003df0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003e00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003e10| 20 20 20 20 20 20 20 20 | 20 20 53 57 41 50 20 48 | | SWAP H|
|00003e20| 4f 4c 44 24 28 4b 29 2c | 20 48 4f 4c 44 24 28 4b |OLD$(K),| HOLD$(K|
|00003e30| 2b 31 29 3a 0d 0a 20 20 | 20 20 20 20 20 20 20 20 |+1):.. | |
|00003e40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003e50| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003e60| 20 20 20 53 57 41 50 20 | 4f 52 49 47 28 4b 29 20 | SWAP |ORIG(K) |
|00003e70| 2c 20 4f 52 49 47 28 4b | 2b 31 29 0d 0a 20 20 20 |, ORIG(K|+1).. |
|00003e80| 20 20 35 32 30 30 20 20 | 20 20 4e 45 58 54 20 4b | 5200 | NEXT K|
|00003e90| 0d 0a 20 20 20 20 20 35 | 32 31 30 20 27 0d 0a 20 |.. 5|210 '.. |
|00003ea0| 20 20 20 20 35 32 32 30 | 20 20 20 20 4c 41 53 54 | 5220| LAST|
|00003eb0| 20 3d 20 4c 41 53 54 20 | 2d 20 31 20 20 20 20 20 | = LAST |- 1 |
|00003ec0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003ed0| 20 20 20 20 20 27 44 45 | 43 52 45 4d 45 4e 54 20 | 'DE|CREMENT |
|00003ee0| 4c 4f 4f 50 20 4c 49 4d | 49 54 0d 0a 20 20 20 20 |LOOP LIM|IT.. |
|00003ef0| 20 35 32 33 30 20 27 0d | 0a 20 20 20 20 20 35 32 | 5230 '.|. 52|
|00003f00| 34 30 20 57 45 4e 44 20 | 20 20 20 20 20 20 20 20 |40 WEND | |
|00003f10| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003f20| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 27 | | '|
|00003f30| 47 4f 20 41 4e 44 20 4d | 41 4b 45 20 41 4e 4f 54 |GO AND M|AKE ANOT|
|00003f40| 48 45 52 0d 0a 20 20 20 | 20 20 35 32 35 30 20 27 |HER.. | 5250 '|
|00003f50| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003f60| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003f70| 20 20 20 20 20 20 20 20 | 20 20 20 20 50 41 53 53 | | PASS|
|00003f80| 20 49 53 20 4e 45 43 45 | 53 53 41 52 59 0d 0a 20 | IS NECE|SSARY.. |
|00003f90| 20 20 20 20 35 32 36 30 | 20 52 45 54 55 52 4e 0d | 5260| RETURN.|
|00003fa0| 0a 0d 0a 0d 0a 20 20 20 | 20 20 54 68 65 20 6f 6e |..... | The on|
|00003fb0| 6c 79 20 72 65 61 6c 20 | 64 69 66 66 65 72 65 6e |ly real |differen|
|00003fc0| 63 65 20 62 65 74 77 65 | 65 6e 20 74 68 69 73 20 |ce betwe|en this |
|00003fd0| 61 6e 64 20 6f 75 72 20 | 6f 74 68 65 72 20 72 6f |and our |other ro|
|00003fe0| 75 74 69 6e 65 20 69 73 | 20 74 68 61 74 20 77 65 |utine is| that we|
|00003ff0| 0d 0a 20 20 20 20 20 63 | 72 65 61 74 65 20 61 6e |.. c|reate an|
|00004000| 64 20 72 65 74 75 72 6e | 20 4f 52 49 47 28 29 2c |d return| ORIG(),|
|00004010| 20 74 68 65 20 73 6f 72 | 74 65 64 20 74 61 62 6c | the sor|ted tabl|
|00004020| 65 20 6f 66 20 6f 72 69 | 67 69 6e 61 6c 20 6c 6f |e of ori|ginal lo|
|00004030| 63 61 74 69 6f 6e 73 2e | 20 20 42 6f 74 68 0d 0a |cations.| Both..|
|00004040| 20 20 20 20 20 4f 52 49 | 47 28 29 20 61 6e 64 20 | ORI|G() and |
|00004050| 48 4f 4c 44 24 28 29 20 | 6e 65 65 64 20 74 6f 20 |HOLD$() |need to |
|00004060| 62 65 20 64 69 6d 65 6e | 73 69 6f 6e 65 64 20 69 |be dimen|sioned i|
|00004070| 6e 20 79 6f 75 72 20 6d | 61 69 6e 20 70 72 6f 67 |n your m|ain prog|
|00004080| 72 61 6d 2e 20 20 4c 69 | 6b 65 0d 0a 20 20 20 20 |ram. Li|ke.. |
|00004090| 20 61 6e 79 20 6f 74 68 | 65 72 20 74 61 62 6c 65 | any oth|er table|
|000040a0| 20 74 68 65 79 20 6e 65 | 65 64 20 73 70 61 63 65 | they ne|ed space|
|000040b0| 20 61 6c 6c 6f 63 61 74 | 65 64 20 66 6f 72 20 74 | allocat|ed for t|
|000040c0| 68 65 6d 20 69 6e 20 6d | 65 6d 6f 72 79 2e 0d 0a |hem in m|emory...|
|000040d0| 0d 0a 20 20 20 20 20 54 | 68 65 20 6e 65 78 74 20 |.. T|he next |
|000040e0| 70 61 67 65 20 63 6f 6e | 74 61 69 6e 73 20 61 20 |page con|tains a |
|000040f0| 73 61 6d 70 6c 65 20 70 | 72 6f 67 72 61 6d 20 74 |sample p|rogram t|
|00004100| 6f 20 73 68 6f 77 20 79 | 6f 75 20 68 6f 77 20 74 |o show y|ou how t|
|00004110| 6f 20 75 73 65 20 74 68 | 65 20 73 6f 72 74 2e 0d |o use th|e sort..|
|00004120| 0a 20 20 20 20 20 41 67 | 61 69 6e 2c 20 6d 6f 73 |. Ag|ain, mos|
|00004130| 74 20 70 72 6f 67 72 61 | 6d 6d 65 72 73 20 6e 65 |t progra|mmers ne|
|00004140| 76 65 72 20 68 61 76 65 | 20 74 6f 20 77 72 69 74 |ver have| to writ|
|00004150| 65 20 61 20 73 6f 72 74 | 20 72 6f 75 74 69 6e 65 |e a sort| routine|
|00004160| 2e 20 20 47 65 6e 65 72 | 61 6c 6c 79 2c 0d 0a 20 |. Gener|ally,.. |
|00004170| 20 20 20 20 74 68 65 73 | 65 20 61 72 65 20 70 61 | thes|e are pa|
|00004180| 72 74 20 6f 66 20 74 68 | 65 20 75 74 69 6c 69 74 |rt of th|e utilit|
|00004190| 79 20 70 72 6f 67 72 61 | 6d 73 20 28 61 20 73 65 |y progra|ms (a se|
|000041a0| 74 20 6f 66 20 70 72 6f | 67 72 61 6d 73 20 74 68 |t of pro|grams th|
|000041b0| 61 74 20 68 61 6e 64 6c | 65 0d 0a 20 20 20 20 20 |at handl|e.. |
|000041c0| 66 72 65 71 75 65 6e 74 | 6c 79 20 6e 65 65 64 65 |frequent|ly neede|
|000041d0| 64 20 74 61 73 6b 73 29 | 20 74 68 61 74 20 63 6f |d tasks)| that co|
|000041e0| 6d 65 20 77 69 74 68 20 | 61 20 63 6f 6d 70 75 74 |me with |a comput|
|000041f0| 65 72 2e 20 20 49 66 20 | 6e 6f 74 2c 20 74 68 65 |er. If |not, the|
|00004200| 79 20 61 72 65 0d 0a 20 | 20 20 20 20 70 75 72 63 |y are.. | purc|
|00004210| 68 61 73 65 64 20 66 72 | 6f 6d 20 63 6f 6d 70 61 |hased fr|om compa|
|00004220| 6e 69 65 73 20 74 68 61 | 74 20 73 70 65 63 69 61 |nies tha|t specia|
|00004230| 6c 69 7a 65 20 69 6e 20 | 77 72 69 74 69 6e 67 20 |lize in |writing |
|00004240| 74 68 65 6d 2e 20 20 53 | 6f 72 74 20 72 6f 75 74 |them. S|ort rout|
|00004250| 69 6e 65 73 0d 0a 20 20 | 20 20 20 61 72 65 20 75 |ines.. | are u|
|00004260| 73 65 64 20 73 6f 20 66 | 72 65 71 75 65 6e 74 6c |sed so f|requentl|
|00004270| 79 20 74 68 61 74 20 74 | 68 65 79 20 68 61 76 65 |y that t|hey have|
|00004280| 20 74 6f 20 62 65 20 65 | 78 74 72 65 6d 65 6c 79 | to be e|xtremely|
|00004290| 20 65 66 66 69 63 69 65 | 6e 74 2e 0d 0a 0d 0a 0d | efficie|nt......|
|000042a0| 0a 0d 0a 0d 0a 0d 0a 0d | 0a 20 20 20 20 20 20 20 |........|. |
|000042b0| 20 20 20 20 20 20 20 20 | 20 20 1b 45 20 20 20 20 | | .E |
|000042c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 1b 46 20 20 | | .F |
|000042d0| 20 20 20 20 20 1b 45 20 | 31 30 32 0d 0a 0d 0a 0c | .E |102.....|
|000042e0| 0d 0a 0d 0a 0d 0a 0d 0a | 1b 46 20 20 20 20 20 1b |........|.F .|
|000042f0| 45 43 48 41 50 54 45 52 | 20 38 1b 46 20 20 20 20 |ECHAPTER| 8.F |
|00004300| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 1b 45 53 | | .ES|
|00004310| 4f 52 54 49 4e 47 20 49 | 54 20 41 4c 4c 20 4f 55 |ORTING I|T ALL OU|
|00004320| 54 20 20 1b 46 20 20 20 | 20 20 20 20 20 20 20 20 |T .F | |
|00004330| 20 20 20 20 20 20 1b 45 | 43 48 41 50 54 45 52 20 | .E|CHAPTER |
|00004340| 38 0d 0a 0d 0a 0d 0a 20 | 20 20 20 20 1b 46 44 6f |8...... | .FDo|
|00004350| 6e 27 74 20 66 6f 72 67 | 65 74 2c 20 74 68 69 73 |n't forg|et, this|
|00004360| 20 70 72 6f 67 72 61 6d | 20 6e 65 65 64 73 20 74 | program| needs t|
|00004370| 68 65 20 73 75 62 72 6f | 75 74 69 6e 65 20 6f 6e |he subro|utine on|
|00004380| 20 74 68 65 20 70 72 65 | 76 69 6f 75 73 20 70 61 | the pre|vious pa|
|00004390| 67 65 2e 0d 0a 0d 0a 20 | 20 20 20 20 31 30 30 20 |ge..... | 100 |
|000043a0| 44 49 4d 20 46 4c 49 47 | 48 54 24 28 35 30 29 2c |DIM FLIG|HT$(50),|
|000043b0| 44 45 53 54 24 28 35 30 | 29 2c 41 52 52 49 56 24 |DEST$(50|),ARRIV$|
|000043c0| 28 35 30 29 2c 48 4f 4c | 44 24 28 35 30 29 2c 4f |(50),HOL|D$(50),O|
|000043d0| 52 49 47 28 35 30 29 0d | 0a 20 20 20 20 20 31 31 |RIG(50).|. 11|
|000043e0| 30 20 27 0d 0a 20 20 20 | 20 20 31 32 30 20 49 4e |0 '.. | 120 IN|
|000043f0| 50 55 54 20 22 48 6f 77 | 20 6d 61 6e 79 20 66 6c |PUT "How| many fl|
|00004400| 69 67 68 74 73 20 64 6f | 20 77 65 20 65 6e 74 65 |ights do| we ente|
|00004410| 72 22 3b 20 54 4f 54 2e | 52 45 43 0d 0a 20 20 20 |r"; TOT.|REC.. |
|00004420| 20 20 31 33 30 20 27 0d | 0a 20 20 20 20 20 31 34 | 130 '.|. 14|
|00004430| 30 20 46 4f 52 20 49 20 | 3d 20 31 20 54 4f 20 54 |0 FOR I |= 1 TO T|
|00004440| 4f 54 2e 52 45 43 0d 0a | 20 20 20 20 20 31 35 30 |OT.REC..| 150|
|00004450| 20 20 20 50 52 49 4e 54 | 20 22 45 6e 74 65 72 20 | PRINT| "Enter |
|00004460| 66 6c 69 67 68 74 2c 20 | 64 65 73 74 69 6e 61 74 |flight, |destinat|
|00004470| 69 6f 6e 20 61 6e 64 20 | 61 72 72 69 76 61 6c 20 |ion and |arrival |
|00004480| 74 69 6d 65 22 0d 0a 20 | 20 20 20 20 31 36 30 20 |time".. | 160 |
|00004490| 20 20 49 4e 50 55 54 20 | 46 4c 49 47 48 54 24 28 | INPUT |FLIGHT$(|
|000044a0| 49 29 2c 20 44 45 53 54 | 24 28 49 29 2c 41 52 52 |I), DEST|$(I),ARR|
|000044b0| 49 56 24 28 49 29 0d 0a | 20 20 20 20 20 31 37 30 |IV$(I)..| 170|
|000044c0| 20 20 20 50 52 49 4e 54 | 0d 0a 20 20 20 20 20 31 | PRINT|.. 1|
|000044d0| 38 30 20 4e 45 58 54 20 | 49 0d 0a 20 20 20 20 20 |80 NEXT |I.. |
|000044e0| 31 39 30 20 27 0d 0a 20 | 20 20 20 20 32 30 30 20 |190 '.. | 200 |
|000044f0| 46 4f 52 20 49 20 3d 20 | 31 20 54 4f 20 54 4f 54 |FOR I = |1 TO TOT|
|00004500| 2e 52 45 43 0d 0a 20 20 | 20 20 20 32 31 30 20 20 |.REC.. | 210 |
|00004510| 20 48 4f 4c 44 24 28 49 | 29 20 3d 20 46 4c 49 47 | HOLD$(I|) = FLIG|
|00004520| 48 54 24 28 49 29 20 20 | 20 20 20 20 20 20 20 20 |HT$(I) | |
|00004530| 20 20 20 20 20 20 20 20 | 20 20 20 20 27 53 45 54 | | 'SET|
|00004540| 20 55 50 20 46 4f 52 20 | 53 4f 52 54 0d 0a 20 20 | UP FOR |SORT.. |
|00004550| 20 20 20 32 32 30 20 4e | 45 58 54 20 49 0d 0a 20 | 220 N|EXT I.. |
|00004560| 20 20 20 20 32 33 30 20 | 27 0d 0a 20 20 20 20 20 | 230 |'.. |
|00004570| 32 34 30 20 47 4f 53 55 | 42 20 35 30 30 30 20 20 |240 GOSU|B 5000 |
|00004580| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004590| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000045a0| 20 27 53 4f 52 54 0d 0a | 20 20 20 20 20 32 35 30 | 'SORT..| 250|
|000045b0| 20 27 0d 0a 20 20 20 20 | 20 32 38 30 20 46 4f 52 | '.. | 280 FOR|
|000045c0| 20 49 20 3d 20 31 20 54 | 4f 20 54 4f 54 2e 52 45 | I = 1 T|O TOT.RE|
|000045d0| 43 0d 0a 20 20 20 20 20 | 32 39 30 20 20 20 4c 20 |C.. |290 L |
|000045e0| 3d 20 4f 52 49 47 28 49 | 29 20 20 20 20 20 20 20 |= ORIG(I|) |
|000045f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004600| 20 20 20 20 20 20 20 20 | 20 27 47 45 54 20 50 4f | | 'GET PO|
|00004610| 49 4e 54 45 52 0d 0a 20 | 20 20 20 20 33 30 30 20 |INTER.. | 300 |
|00004620| 20 20 50 52 49 4e 54 20 | 46 4c 49 47 48 54 24 28 | PRINT |FLIGHT$(|
|00004630| 4c 29 2c 20 44 45 53 54 | 24 28 4c 29 2c 20 41 52 |L), DEST|$(L), AR|
|00004640| 52 49 56 24 28 4c 29 0d | 0a 20 20 20 20 20 33 31 |RIV$(L).|. 31|
|00004650| 30 20 4e 45 58 54 20 49 | 0d 0a 20 20 20 20 20 33 |0 NEXT I|.. 3|
|00004660| 32 30 20 53 54 4f 50 0d | 0a 0d 0a 20 20 20 20 20 |20 STOP.|... |
|00004670| 50 43 20 74 69 6d 65 2c | 20 72 65 76 69 65 77 20 |PC time,| review |
|00004680| 74 68 65 20 61 62 6f 76 | 65 20 61 6e 64 20 74 61 |the abov|e and ta|
|00004690| 6b 65 20 69 74 20 66 6f | 72 20 61 20 74 65 73 74 |ke it fo|r a test|
|000046a0| 20 72 69 64 65 2e 0d 0a | 0d 0a 0d 0a 20 20 20 20 | ride...|.... |
|000046b0| 20 1b 45 53 50 45 43 49 | 46 49 43 41 54 49 4f 4e | .ESPECI|FICATION|
|000046c0| 0d 0a 0d 0a 20 20 20 20 | 20 1b 46 41 6e 64 20 6e |.... | .FAnd n|
|000046d0| 6f 77 2c 20 6f 75 72 20 | 66 72 69 65 6e 64 6c 79 |ow, our |friendly|
|000046e0| 20 61 6e 61 6c 79 73 74 | 20 68 61 73 20 61 6e 6f | analyst| has ano|
|000046f0| 74 68 65 72 20 6a 6f 62 | 20 66 6f 72 20 79 6f 75 |ther job| for you|
|00004700| 2e 20 20 49 74 20 73 65 | 65 6d 73 20 74 68 61 74 |. It se|ems that|
|00004710| 0d 0a 20 20 20 20 20 4d | 65 72 6c 69 6e 20 69 73 |.. M|erlin is|
|00004720| 20 73 74 69 6c 6c 20 6e | 6f 74 20 73 61 74 69 73 | still n|ot satis|
|00004730| 66 69 65 64 20 77 69 74 | 68 20 74 68 65 20 70 72 |fied wit|h the pr|
|00004740| 6f 67 72 61 6d 20 74 68 | 61 74 20 77 61 73 20 70 |ogram th|at was p|
|00004750| 72 6f 64 75 63 65 64 20 | 61 74 20 74 68 65 0d 0a |roduced |at the..|
|00004760| 20 20 20 20 20 65 6e 64 | 20 6f 66 20 63 68 61 70 | end| of chap|
|00004770| 74 65 72 20 37 2e 20 20 | 4d 6f 72 65 20 73 70 65 |ter 7. |More spe|
|00004780| 63 69 66 69 63 61 6c 6c | 79 2c 20 68 65 20 77 61 |cificall|y, he wa|
|00004790| 6e 74 73 20 74 68 65 20 | 70 72 6f 67 72 61 6d 20 |nts the |program |
|000047a0| 75 70 67 72 61 64 65 64 | 0d 0a 20 20 20 20 20 61 |upgraded|.. a|
|000047b0| 67 61 69 6e 2e 20 20 44 | 69 64 6e 27 74 20 62 65 |gain. D|idn't be|
|000047c0| 6c 69 65 76 65 20 75 73 | 20 77 68 65 6e 20 77 65 |lieve us| when we|
|000047d0| 20 74 6f 6c 64 20 79 6f | 75 20 68 6f 77 20 6d 75 | told yo|u how mu|
|000047e0| 63 68 20 74 69 6d 65 20 | 69 73 20 73 70 65 6e 74 |ch time |is spent|
|000047f0| 20 6f 6e 0d 0a 20 20 20 | 20 20 6d 61 69 6e 74 65 | on.. | mainte|
|00004800| 6e 61 6e 63 65 20 70 72 | 6f 67 72 61 6d 6d 69 6e |nance pr|ogrammin|
|00004810| 67 2c 20 64 69 64 20 79 | 6f 75 3f 0d 0a 0d 0a 20 |g, did y|ou?.... |
|00004820| 20 20 20 20 54 68 65 20 | 75 70 67 72 61 64 65 64 | The |upgraded|
|00004830| 20 73 70 65 63 69 66 69 | 63 61 74 69 6f 6e 73 20 | specifi|cations |
|00004840| 61 72 65 3a 0d 0a 0d 0a | 0d 0a 20 20 20 20 20 20 |are:....|.. |
|00004850| 20 20 20 20 2d 20 20 41 | 64 64 20 74 68 65 20 66 | - A|dd the f|
|00004860| 6f 6c 6c 6f 77 69 6e 67 | 20 6f 70 74 69 6f 6e 73 |ollowing| options|
|00004870| 2c 20 61 6e 64 20 61 73 | 73 6f 63 69 61 74 65 64 |, and as|sociated|
|00004880| 20 6c 6f 67 69 63 3a 0d | 0a 0d 0a 20 20 20 20 20 | logic:.|... |
|00004890| 20 20 20 20 20 20 20 20 | 34 20 20 2d 20 20 44 69 | |4 - Di|
|000048a0| 73 70 6c 61 79 20 74 68 | 65 20 69 6e 66 6f 72 6d |splay th|e inform|
|000048b0| 61 74 69 6f 6e 20 6f 6e | 20 61 6c 6c 20 73 70 65 |ation on| all spe|
|000048c0| 6c 6c 73 20 73 6f 72 74 | 65 64 20 62 79 20 73 70 |lls sort|ed by sp|
|000048d0| 65 6c 6c 20 6e 61 6d 65 | 0d 0a 20 20 20 20 20 20 |ell name|.. |
|000048e0| 20 20 20 20 20 20 20 35 | 20 20 2d 20 20 44 69 73 | 5| - Dis|
|000048f0| 70 6c 61 79 20 74 68 65 | 20 69 6e 66 6f 72 6d 61 |play the| informa|
|00004900| 74 69 6f 6e 20 6f 6e 20 | 61 6c 6c 20 73 70 65 6c |tion on |all spel|
|00004910| 6c 73 20 73 6f 72 74 65 | 64 20 62 79 20 73 70 65 |ls sorte|d by spe|
|00004920| 6c 6c 20 63 6f 73 74 0d | 0a 20 20 20 20 20 20 20 |ll cost.|. |
|00004930| 20 20 20 20 20 20 36 20 | 20 2d 20 20 54 65 72 6d | 6 | - Term|
|00004940| 69 6e 61 74 65 0d 0a 0d | 0a 20 20 20 20 20 47 6f |inate...|. Go|
|00004950| 20 74 6f 20 69 74 2e 20 | 20 52 65 6d 65 6d 62 65 | to it. | Remembe|
|00004960| 72 2c 20 4d 65 72 6c 69 | 6e 20 63 61 6e 20 66 69 |r, Merli|n can fi|
|00004970| 6e 64 20 79 6f 75 20 61 | 6e 79 20 74 69 6d 65 20 |nd you a|ny time |
|00004980| 61 6e 64 20 61 6e 64 20 | 61 6e 79 20 70 6c 61 63 |and and |any plac|
|00004990| 65 2e 20 20 48 65 0d 0a | 20 20 20 20 20 68 61 73 |e. He..| has|
|000049a0| 20 61 6c 73 6f 20 67 6f | 74 74 65 6e 20 6d 6f 72 | also go|tten mor|
|000049b0| 65 20 67 72 75 6d 70 79 | 20 61 6e 64 20 73 65 65 |e grumpy| and see|
|000049c0| 6d 73 20 74 6f 20 66 65 | 65 6c 20 74 68 61 74 20 |ms to fe|el that |
|000049d0| 62 65 69 6e 67 20 74 75 | 72 6e 65 64 20 69 6e 74 |being tu|rned int|
|000049e0| 6f 20 61 0d 0a 20 20 20 | 20 20 74 6f 61 64 20 69 |o a.. | toad i|
|000049f0| 73 20 74 6f 6f 20 67 6f | 6f 64 20 66 6f 72 20 61 |s too go|od for a|
|00004a00| 6e 79 62 6f 64 79 20 77 | 68 6f 20 66 61 69 6c 73 |nybody w|ho fails|
|00004a10| 20 74 6f 20 73 61 74 69 | 73 66 79 20 68 69 73 20 | to sati|sfy his |
|00004a20| 6e 65 77 20 66 6f 75 6e | 64 20 64 65 6d 61 6e 64 |new foun|d demand|
|00004a30| 0d 0a 20 20 20 20 20 66 | 6f 72 20 68 69 67 68 20 |.. f|or high |
|00004a40| 74 65 63 68 6e 6f 6c 6f | 67 79 2e 20 20 41 72 65 |technolo|gy. Are|
|00004a50| 20 79 6f 75 20 73 74 69 | 6c 6c 20 73 75 72 65 20 | you sti|ll sure |
|00004a60| 79 6f 75 20 77 61 6e 74 | 20 74 6f 20 62 65 20 61 |you want| to be a|
|00004a70| 20 70 72 6f 67 72 61 6d | 6d 65 72 3f 0d 0a 0d 0a | program|mer?....|
|00004a80| 0d 0a 0d 0a 0d 0a 0d 0a | 0d 0a 0d 0a 20 20 20 20 |........|.... |
|00004a90| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 1b 45 20 | | .E |
|00004aa0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 1b | | .|
|00004ab0| 46 20 20 20 20 20 20 20 | 1b 45 20 31 30 33 0d 0a |F |.E 103..|
|00004ac0| 0d 0a 1b 46 20 0d 0a 1b | 32 1b 55 00 1b 39 0c 1b |...F ...|2.U..9..|
|00004ad0| 48 1a 6c 20 6e 61 6d 65 | 0d 0a 20 20 20 20 20 20 |H.l name|.. |
|00004ae0| 20 20 20 20 20 20 20 35 | 20 20 2d 20 20 44 69 73 | 5| - Dis|
|00004af0| 70 6c 61 79 20 74 68 65 | 20 69 6e 66 6f 72 6d 61 |play the| informa|
|00004b00| 74 69 6f 6e 20 6f 6e 20 | 61 6c 6c 20 73 70 65 6c |tion on |all spel|
|00004b10| 6c 73 20 73 6f 72 74 65 | 64 20 62 79 20 73 70 65 |ls sorte|d by spe|
|00004b20| 6c 6c 20 63 6f 73 74 0d | 0a 20 20 20 20 20 20 20 |ll cost.|. |
|00004b30| 20 20 20 20 20 20 36 20 | 20 2d 20 20 54 65 72 6d | 6 | - Term|
|00004b40| 69 6e 61 74 65 0d 0a 0d | 0a 20 20 20 20 20 47 6f |inate...|. Go|
|00004b50| 20 74 6f 20 69 74 2e 20 | 20 52 65 6d 65 6d 62 65 | to it. | Remembe|
|00004b60| 72 2c 20 4d 65 72 6c 69 | 6e 20 63 61 6e 20 66 69 |r, Merli|n can fi|
|00004b70| 6e 64 20 79 6f 75 20 61 | 6e 79 20 74 69 6d 65 20 |nd you a|ny time |
|00004b80| 61 6e 64 20 61 6e 64 20 | 61 6e 79 20 70 6c 61 63 |and and |any plac|
|00004b90| 65 2e 20 20 48 65 0d 0a | 20 20 20 20 20 68 61 73 |e. He..| has|
|00004ba0| 20 61 6c 73 6f 20 67 6f | 74 74 65 6e 20 6d 6f 72 | also go|tten mor|
|00004bb0| 65 20 67 72 75 6d 70 79 | 20 61 6e 64 20 73 65 65 |e grumpy| and see|
|00004bc0| 6d 73 20 74 6f 20 66 65 | 65 6c 20 74 68 61 74 20 |ms to fe|el that |
|00004bd0| 62 65 69 6e 67 20 74 75 | 72 6e 65 64 20 69 6e 74 |being tu|rned int|
|00004be0| 6f 20 61 0d 0a 20 20 20 | 20 20 74 6f 61 64 20 69 |o a.. | toad i|
|00004bf0| 73 20 74 6f 6f 20 67 6f | 6f 64 20 66 6f 72 20 61 |s too go|od for a|
+--------+-------------------------+-------------------------+--------+--------+